About Target display mode on an iMac
Here in the Apple Support Community (ASC) on a regular base we get questions about using an older iMac as a display for a newer one. Target display mode was a feature once, but it is discontinued now and the chances that you can use it are low.
Target display mode was introduced with the 2009 27in and 24in iMac. The feature remained present on iMacs from the ages 2009-2014. Where in 2009 only the 27 and 24 inch versions got the feature, from 2010 to 2014 every iMac got the possibility of using target display mode. But after that years, the feature disappaered from iMacs.
In that time, it was possible to use target display mode. But, there are a few limitations to the feature that will make it very difficult to use this feature in current times. First, the iMac that you want to use as a display needs to have macOS High Sierra or earlier installed. High Sierra is a relatively old version of macOS, but of course, if you're only using it as a display (or you have a 2009, 2010 or 2011 iMac that cannot update further then High Sierra) this will not be the biggest problem. The biggest problem will be the source Mac, the Mac that you want to be displayed on your iMac. That one needs to be introduced in 2019, and needs to have macOS Catalina or earlier installed.
An example: If you're having a 2019 MacBook Pro and an 2014 iMac, and the 2019 MacBook Pro has been updated to Sonoma, even when your 2014 iMac is physically capable of performing target display mode, it will not work because your MacBook Pro is up to date.
Using target display mode is completely impossible with Apple Silicon Macs. As the source computer will need to have Catalina or lower installed and Catalina was never avaliable for Macs with apple silicon.
Unfortunately, it has become almost impossible to use your old iMac as a display using target display mode.
Is it completely impossible to use your old Mac as a display? Well, not entirely. There are some third party solutions you can try, and with a newer older iMac that is capable of running macOS Monterey you can use airplay to Mac to share your screen. But, using an iMac as second screen will draw more power then just an external display. And for this reason, I would reccommend against using your iMac as a second display and just go with a monitor instead. This will not only save you the hassle, but it will save you money, as an iMac draws more power then an external monitor.