Try this:
PRINT THESE INSTRUCTIONS OUT AND CHECK THEM OFF AS YOU GO ALONG:
1. Press the power on button and keep holding it in until the Mac shuts off. You're going to start over.
2. Press the power on button and IMMEDIATELY hold down the Command, option and R keys ("command-option-R"). KEEP HOLDING THEM DOWN.
3. You should now boot into internet recovery. IF you're connecting via wifi, you may need to enter your wifi password.
4. Open Disk Utility, but don't do anything yet
5. Look in the upper-left-hand corner. See that "view" menu?
6. Choose "Show ALL devices".
7. You should now see the representation for the physical drive inside the iMac -- it will the TOPMOST item "on the list" on the left.
8. Click that item, then click "erase" (upper right)
9. Choose "Mac OS extended with journaling enabled" (GUID partition format).
(note: if your only choice is APFS, choose that, but try Mac OS extended first)
10. Let Disk Utility erase the drive
11. Close Disk Utility and open the OS installer
12. See if the installer will install a fresh copy of the OS now. The computer may reboot once or twice in the process. Expect this to take a while.
13. When done, you should be presented with a setup screen to set up the new OS.