Modern Mac models all use SSD. From your description, I know that your iMac is an old one. How did you format your internal HDD?
You need to select the entire HDD in Disk Utility, click Erase, and then fill in the information boxes, including the disk name, format, and scheme. Finally, click Erase. Initializing the internal HDD will take a relatively long time. During the process, don't let your iMac power off or the screen down.
If you still can't initialize the HDD, run First Aid to check it first and then try again.
I suggest you recover data on your HDD under this circumstance to avoid data loss. You can use iBoysoft Mac Recovery Mode to rescue your files from your unbootable iMac without creating a bootable USB installer.