I think you need to upgrade your iMac to High Sierra or better for it to be able to manage an iPhone that is running iOS 17. I've seen people here say that the requirements to manage an iPhone are really tied more to the version of iOS that it is running, than to its hardware model.
If that's the case, then the Technical Specifications for iPhone 15 family phones (which initially shipped with iOS 17) give you an idea as to what you need to manage any iPhone that's been upgraded to iOS 17:
iPhone 15 - Technical Specifications
As others have pointed out, you can upgrade a 2012 iMac to Catalina (but no further). If you upgrade to Catalina,
You can get High Sierra, Mojave, or Catalina from here:
How to download and install macOS - Apple Support
Have Safari set as your default browser, and use Safari, when visiting that page. Otherwise clicking on the links to download one of those OSes may result in an very misleading error ("this item is unavailable").