Okay, try usual first… reset smc/pmu followed by 3-4 pram zaps on startup, per this link:
https://www.macworld.com/article/224955/how-to-reset-a-macs-nvram-pram-and-smc.html
… you should have wired usb keyboard, use that… restart holding down “D” key for Apple Diagnostics…
if you want to try Internet recovery, make sure Ethernet cable is connected from modem/router to Ethernet port on back of iMac… to try that, restart holding down … see link : Use macOS Recovery on an Intel-based Mac - Apple Support (CA)
you should see spinning globe + progress bar on screen, when bar is full internet recovery will start… if not try recovery partition, hold down Apple/clover leaf/command key + R together on startup to get to that, pick language, continue, to get to Mac OS X tools, move cursor/mouse/trackpad to top centre of screen and click, and there they’ll be… from there you should be able to reinstall the Mac OS..make sure to set your internal hard drive as the boot up/ start up drive then restart after you have reinstalled the Mac OS…
hope this helped you
John B