To my knowledge that feature has long since been removed.
https://support.apple.com/en-us/HT204592
You can use mac-to-mac airplay, but it's only available on the latest version (beta) of Monterey and only if you're using a modern mac (which I assume your iMac is).
https://www.apple.com/macos/monterey/features/
To use it as an external monitor.
To my knowledge that feature has long since been removed.
https://support.apple.com/en-us/HT204592