Note that most of us here cannot officially speak for warranty, but I can tell you from my experience here.
If you are still under warranty then yes, changing parts in the computer can void the warranty. If you had to send it in for repairs, the HP Service Center can reject it for not having the original parts in it.
You would have to replace what ever you changed, back to the original part before having it serviced.
If you are not in warranty anymore, then you don't need to worry about it.