It seems you have an iMac 27" (2017) model.
The easiest option would be to boot into Internet Recovery Mode using Command + Option + R to attempt to access the online Ventura installer. Some Macs may only access the online installer for the OS which originally shipped with the Mac from the factory which for your Mac is macOS 10.12 Sierra which can also be used (theoretically depending if Apple has broken it....may also be possible to fix it as well if it is broken).
If your local network or Internet is not sufficient for accessing the online installers, then you can create & use a bootable macOS USB installer, but you must follow the instructions exactly in the Apple article @jeffreythefrog linked. You will need access to another Mac generally from 2017 to mid-mid-2023 in order to download & create the bootable Ventura USB installer.
FYI, you do not copy the installer to the external drive since the installer you download is just a regular app.....you need to use the Terminal command line as mentioned in the Apple article @jeffreythefrog linked in order to actually create a bootable macOS Ventura USB installer from the downloaded Ventura installer app.
More than likely the iMac's internal Hard Drive has failed as that is the most likely reason to get the folder with blinking question mark. If the internal Hard Drive has failed, then the "easiest" option would be to install macOS onto an external USB3 SSD so you can continue using the iMac by booting & running it from the external SSD.
You can try running the Apple Diagnostics to see if any hardware issues are detected. If a drive failure is shown, then at least you have your answer, however, unfortunately the diagnostics rarely detect hardware issues even when a hardware issue is confirmed through other methods.