Sorry for the delay.
When the MacBook’s lid is closed, normally you shouldn’t even be able to connect at all. Unfortunately this is prevented by the system, unless you use an external app that prevents system sleep, plug a fake display adapter or keep an active ssh connection to the MackBook. Also the NoMachine built-in Wake-on-LAN feature may help, depending on system and network configuration. If I understand, you seem to be able to connect, but you get a black screen. Are you using any of those methods to keep the machine awake? Are you still using the Beta version of Monterey?