Yes you can because the interface of the SSD and the HP is compatible, the SSD is replaceable.
I can't tell you what happens to the warranty when you open the case because you have to remove the adhesive feet, which is common with consumer devices.
There are various instructions on the internet for 13 or 15 inch depending on the model.
Here are the instructions for the 13 inch model.
https://www.myfixguide.com/hp-envy-x3...
Attention: at your own risk, if something is defective afterwards, you will not get any guarantee or warranty.