An iMac G5 would be a PowerPC-based iMac released between August 2004 and October 2005. The highest version of the OS that it could run would be Mac OS X 10.5.8 (Leopard), the last version of Mac OS X that was available for any PowerPC-based Mac.
The iPhone 12 originally only supported manual synchronization with Macs that were running OS X 10.11.6 (El Capitan) and later. If you have updated your iPhone 12 to iOS 17 or 18, manual synchronization probably now requires Macs that are running Mac OS X 10.3.* (High Sierra) or later. Only Apple Silicon Macs and some Intel Macs are recent enough to satisfy these requirements.
In either case, an iMac G5 would be far, far too old to manage an iPhone 12.
iPhone 12 - Technical Specifications - Apple Support