A screen saver looks like a lock, but if the Mac waits a few minutes before it asks for a password, anyone who wiggles the mouse in that window gets in.
Open System Settings and click Lock Screen. The setting is called “Require password after screen saver begins or display is turned off”, and next to it you pick how long the Mac waits.
System Settings > Lock Screen
Require password after screen saver begins
or display is turned off: Immediately
Apple describes it as locking your Mac when it’s left idle: when it wakes, a login password is needed, and you choose the amount of time after the screen saver or sleep begins before that happens. I’d pick Immediately on a laptop that leaves the house. A grace period of a few minutes is only comfortable at home.
The same pane has the timers that start it all: “Turn display off on battery when inactive” and the same for the power adapter. A shorter time there means the lock kicks in sooner when you walk away and forget.
While you’re there, “Show message when locked” lets you put a short line on the login window. Apple suggests contact information, which is useful if the MacBook is ever lost.
The trade-off is small annoyances: with Immediately, the Mac asks for Touch ID or your password every time the display goes dark. If that happens while you’re reading, raise the display timer instead of the password delay.
Further reading: Change Lock Screen settings on Mac (Apple)