It’s good that you’re okay with starting from scratch, the best way being to erase the hard drive and reinstall a brand new OS. However, there is no easy way to do this if you are unable to get into recovery or internet recovery mode. I suggest, at this point, to try resetting the SMC. If I remember right, with the iMac, all you need to do is pull the power cord from the Mac, wait 15 seconds, then plugging it back in. Wait another 10 to 15 seconds and press the power button.
If it starts up, and if you still experience the problem with System Preferences not recognizing your login password, try zapping the parameter RAM (PRAM). From the iMac powered down, restart and immediately hold down the command-option-P-R keys simultaneously until you hear the startup chime TWICE. Let go and allow it to start up normally. If you still have trouble with System Preferences not recognizing your admin password, you could try creating a new user with admin status, then restart and log in with the new user. If the problem persists, you may need to try recovery mode again.
From recovery mode, I suggest wiping the hard drive by invoking Disk Utility to erase the disk, and afterwards, opting to reinstall macOS.
Good luck!