Several MacMaven clients have inquired about whether their old iMac can be used as an external monitor with a recent Mac model. The short answer is it depends. It depends on the specific Mac models, whether DisplayPort or Thunderbolt is being used, and the operating system versions of each computer. The community consensus is that Apple Silicon Macs will not work with Thunderbolt-based TDM. Regardless of whether a particular combination of devices works today, I would not recommend using Target Display Mode at this time. Apple does not support its use with any current Mac. Even if a particular combination of devices worked, it could break with a future macOS update.
An older iMac could be used as a second display using products like Duet or Luna. Open source solutions include FluffyDisplay and BetterDisplay. If your Mac is running Monterey or newer, it can be set up as an AirPlay receiver.