@thomasfuchs this section sounds relevant:
If you use your Mac laptop with the lid closed
First, you need to allow an external display, a mouse, and a keyboard to connect to your Mac laptop. Then you can use your Mac with the lid closed (or with a docking station in which you place your Mac with the lid closed), and allow other accessories to connect without opening the lid.