How to disable clamshell mode behaviour? Force machine lock on lid close
Sadly I don't think you can invoke this behavior and this is not the solution you are asking for, though as I imagine you are using a keyboard (apple?) you could always use the hotkeys to lock your laptop and screen.


Option–Command–Power / Option–Command–Media Eject: Put Mac to
sleep
Control–Shift–Power / Control–Shift–Media Eject : Put
display(s) to sleep


https://support.apple.com/en-us/HT201236