using this as a reference:
https://support.hp.com/us-en/document/c03859136

You do have a PCIE 16X so it should be able to support a decent graphics card, but it also has a tiny power supply, so that would likely have to be upgraded as well, hopefully it uses standard form factors and isn't some weird proprietary shaped thing (HP used to do that back when I did computer repair, like 5 years ago). If you know a PC guy or have someone local have them take a look, any competent techie should be able to give it a quick once over and advise a strategy.
You are probably looking at at least $250+ for parts, depending on how crazy you want to go. I would also take a look at upgrading your windows 7 to either a 64 bit version of the same or just upgrading to windows 10 64 bit version as it will allow more ram to be used. I haven't looked into what's available now but there have always been free opportunities to upgrade in recent years.