Sorry, not possible in the normal sense...
iMac models introduced in 2011, 2012, 2013, and mid 2014
To use any of these iMac models as an external display:
- The iMac used as a display must have macOS High Sierra or earlier installed.
- The other Mac that you're connecting it to must have been introduced in 2019 or earlier and have macOS Catalina or earlier installed.
- The cable connecting the two Mac computers must be a Thunderbolt
or Thunderbolt 2
cable.
24-inch and 27-inch iMac models introduced in 2009 and 2010
To use any of these iMac models as an external display:
- The iMac used as a display must have macOS High Sierra or earlier installed.
- The other Mac that you're connecting it to must have been introduced in 2019 or earlier and have macOS Catalina or earlier installed.
- The cable connecting the two Mac computers must be a Mini DisplayPort
cable.
Use your iMac as a display with target display mode - Apple Support
I haven't tried it, but Turn any Mac or iPad into a second display...
https://lunadisplay.com/
https://www.duetdisplay.com/
Duet - Remote Desktop, Second Display, Drawing Tablet, and More (duetdisplay.com)
Review by NAK005, you may not be happy with it…
Secondary Screen Solution - Apple Community