If this is a Late 2009 iMac, then it may have access to Internet Recovery Mode (Command + Option + R) if macOS 10.12.6+ was ever installed on it.
If this is an Early or Mid 2009 iMac and you cannot enter local Recovery Mode, then you will either need to use the original OS X 10.6 Restoration DVD which originally shipped with the iMac from the factory to get a basic OS on it so later versions of macOS can be accessed. Or you will need access to another Qualifying Mac in order to create a bootable macOS 10.11 El Capitan USB installer. A Qualifying Mac for macOS 10.11 is generally one from 2008 to 2015, but you can confirm by checking this article which shows which versions of macOS are compatible with various hardware:
FYI, any computer (even Windows) can download the macOS 10.11 installer from Apple since it is available outside of the App Store, but only a Qualifying Mac (aka one which is compatible with macOS 10.11) can run the .pkg file in the downloaded .dmg file to extract the real installer to the Applications folder). Here is an Apple article with instructions for creating a bootable macOS USB installer:
Create a bootable installer for macOS - Apple Support
You can try using DiskMaker X to create the bootable macOS USB installer as it may allow you to use any Mac compatible with the DiskMaker X app, but I have not tried this option.
These are your only options for reinstalling macOS.