Chosen Solution

I have recently become aware that the 2017 imac does not support spdif through headphone jack anymore. Is it possible to replace the jack with the optical jack from a 2015 model?

Sorry no the needed connections are not present for the optical transmitter within the jack. You can get an external USB DAC unit which we use.