Here’s the $9 cable you need.
However, I would recommend getting a $30 Google Chromecast instead, as this will make your life easier and you don’t have to worry about wires and you can play from any device, not just your iMac.
This is just an example, not a recommendation for this product.
Edit: or this is you just want to go direct without an intermediate cable: https://www.amazon.com/AmazonBasics-DisplayPort-Display-Adapter-Cable/dp/B0134V3KIA/ref=sr_1_3?crid=3BARZ2OUWJ7IR&keywords=mini%2Bdisplayport%2Bto%2Bhdmi&qid=1682597841&sprefix=mini%2Bdispl%2Caps%2C75&sr=8-3&th=1