You can usually lock the screen by hitting ctrl-shift-power, but that will power down external monitors, which might take several boring seconds to start up again. Also, a MacBook with a TouchBar doesn't have the power button anymore. With the following guide you can lock the screen by starting the screensaver, keeping the monitors running.
Set System Preferences » Security & Privacy » General » ✅ Require password
The simple way
immediately after sleep...
- Download enable-screensaver.zip and unzip it to