Have you tried another HDMI cable?
There are HDMI cables with some type of latching connector.
Here's one - https://www.amazon.com/Accell-B100C-003B-43-AVGrip-Locking-Connectors/dp/B002ISVI4E/
If THAT doesn't help (and the issue is an internal connector that is physically loose, then you have warranty that you can use to get the logic board replaced.