It would help to know what year the iMac was made and what version of the OS had been previously running on it.
When you get to internet recovery, try this:
1. Open disk utility.
2. Go to the menu bar. Is there a "view" menu? If so, choose "Show all devices" if it's there. If it's NOT there, don't worry about this and go to step 3.
3. In disk utility's window, look to the left. Click on the "TOP line" on the left. This represents the actual physical drive inside.
4. Click "erase". Now...
- if you're going to install Mojave or Catalina (I would not install Catalina unless there is no other choice), choose to erase in APFS, with GUID partition format
- if you're going to install High Sierra or something older, choose "Mac OS extended with journaling enabled", GUID partition format
5. Once you choose this, now click the erase button. It shouldn't take long.
6. Now quit disk utility and open the OS installer. Start "clicking through" the screens. The OS install will probably restart the Mac once or twice, the screen may go dark for a little while, and you will see "the progress bar" one or more times.
7. When the OS install is done, you'll see the initial setup screen "choose your language". Begin clicking through from there.
8. If you have a backup, wait until setup assistant asks if you wish to migrate from another Mac or drive. Then connect it and give setup assistant some time to "digest" everything. I suggest you accept all the defaults and migrate everything.
9. If there is no backup, just create another new account and get started all over again...