In order to play Apple Music in hi-res lossless a DAC is needed.
Both Cocktail Audio N25 and Cambridge Audio CXN v2 offer USB input to their DAC sections making them compatible with your iMac.
They are both streamers offering way more features than a "simple" USB DAC. Using them in a chain between your Mac and your Denon would be an overkill, in my opinion:
iMac -> USB -> Cocktail Audio N25/Cambridge Audio CXN v2 -> SPDIF -> Denon AVR X3400n -> Speakers
The Denon X3400n has a USB input (front panel): unfortunately it seems to be a data input only, meaning that it's used to read media files from external storage devices and not to be connected directly to its DAC section acting as an audio input. You can check out by yourself by connecting your iMac and see if it's recognized as an audio output device by your Mac.
Regardless the device used as a DAC, consider that Music app on Mac doesn't offer automatic sample rate switching (i.e. exclusive mode). If you're a bit perfect purist, you'd have to match manually the sample rate for every played track in Audio MIDI Setup on your Mac.
The counterpart Music app on iOS/iPadOS devices offers automatic sample rate switching when connected to a USB DAC.