I've seen bad hard drives cause this before now on iMacs (especially 2011 ones). If the drive is failing, the firmware can struggle to communicate with it, and it can cause lockups like that.
Hate to say it, the only way you're likely to find the issue is to minimal system it- it's how we used to find random errors. Strip the computer down so it's just MLB + 1 stick of RAM + LCD, and try to boot from a USB drive. If it doesn't work, try a different stick of RAM - that will give you a diagnoses of either RAM stick, or MLB.
If it boots as a minimal system, add components back one by one until it fails. On an iMac it's a pain in the backside, but sometimes it's the only way.