I don't think you will be able to do this because of the limitation of the Mac that is trying to use the external display.
"The other Mac that you're connecting it to must have been introduced in 2019 or earlier and have macOS Catalina or earlier installed."
See the support page from Apple...
Target display mode is a feature available with certain older Mac models.
support.apple.com