Macbook + iMac: Use an iMac as a display with AirPlay/target display mode
wikiHow: How to Use an iMac as an External Monitor: Target Display Mode and AirPlay
link: Want to use your iMac's awesome screen as a monitor for your MacBook or Mac desktop? If you're using a newer iMac running macOS Monterey, it's easy to use AirPlay to mirror or extend your screen to an iMac. For older iMacs running High Sierra or earlier, you can use Target Display Mode to set your iMac's screen as your Mac's primary monitor. This wikiHow will show you the easiest ways to use any iMac as a main or secondary display for your Mac.
1. system settings > search "airplay" > turn on 'airplay receiver' (Default)
2. system settings > search "screen mirroring" > select "always show in menu bar"
3. connect your desired device.
better connect with a USB-C or Thunderbolt 3 cable (There is some lag when using a wireless connection.)
Quora: Can you use an iMac as a monitor for a Mac Mini?
Link: Here’s the scoop: if your iMac is a late 2009 model or newer, you're in luck. All you need is a Thunderbolt or Mini DisplayPort cable, and you’re set to turn your iMac into a stunning display for your Mac Mini. Just hook them up, power on both devices, and hold down the Command (⌘) + F2 keys on your iMac's keyboard—that’s the magic combo to trigger Target Display Mode. It’s like your iMac transforms into a brilliant monitor for your Mac Mini, giving you that seamless dual-screen setup.
Apple support: Use your iMac as a display with target display mode
https://recorder.easeus.com/screen-recording-resource/use-imac-as-monitor-for-pc.html
https://recorder.easeus.com/questions/can-you-use-imac-as-a-monitor-for-macbook.html