The biggest issue with pre-built mid-tower machines like those is normally space, case airflow and above all
POWERSUPPLY
usually pre-builts are made to a budget and because of that, a lot of things that make up the computer can be proprietary/custom made to the brand's specification and HP are seriously no stranger to this... they have custom made cases, proprietary motherboards and power supplies etc etc and I think your setup is heavily customised/proprietary to HP judging by the looks of the motherboard and case they have used.
While sticking a new graphics card in should be a fairly simple process. You should make sure you have enough space. Titan X's measured around 10-11" long and 4-5" wide. Id also suggest trying to get more air flow by adding an extra fan in the front of the case. As far I can see the TG-01 only has one rear 120mm which might be
OK for a 5600G and RX5500. It might not be so great with a Titan X although it depends which model of titan they put in your machine.
It could be a blower style cooler like this and you could be ok although I would still insist on adding an extra fan if you can.
Power supply is also an issue in multiple ways as HP dont use off the shelf motherboards so an off the shelf power supply might not be compatible and Titan X Pascal can run with a 450w but you should have a 600w just to be on the safe side. My old 1080Ti used to spike to over 600w occasionally. And i doubt HP would have specced a more beefy power supply with your TG-01 especially if it left the factory with a RX5500.
References:
TG-01 Power supply upgrade
TG-01 motherboard
TG-01 case layout -- Usually down the bottom right hand side is where they stick a hard drive. You might be able to attach a fan there. But im not sure where fan will be drawing air from as the front of the case looks pretty restrictive.
In summary - Yes you can do it, Yes its going to take some messing with, yes it could suck but its your money and you decide what you want to do with it.