You do not need any specific version of the macOS installer here. Assuming you created the bootable macOS 12.6.5 USB installer correctly, it should work. However, maybe the USB stick used is bad or not compatible with booting a Mac. Macs can be very particular about the drives used for booting. Plus the quality of many USB sticks is extremely poor.
Verify you created the bootable macOS USB installer using the instructions in this Apple article:
Create a bootable installer for macOS - Apple Support
If you followed these instructions, but are unable to see the USB stick as a bootable drive, then try using another USB stick, especially a different brand.
There is also a possibility the issues you are trying to fix with a clean install are the same issues preventing you from seeing a bootable installer on the Option Boot screen. I do know that some hard drive failures can be severe enough that they cause the Mac to hang trying to read the failing drive that the system times out looking for any other bootable media.
You may want to try running the Apple Diagnostics to see if any hardware issues are detected. Unfortunately the diagnostics do not detect most drive failures. If you can still boot the iMac normally (or in Safe Mode), then you can check the health of the drive(s) by using DriveDx...feel free to post the complete DriveDx text report for each drive. If the Mac cannot boot into macOS and the diagnostics don't report any problems, then I can provide instructions for creating & using a Linux boot disk to check the health of the drive(s).