The shortcut
Press ⌃ ⌘ Q. The screen locks at once.
The Apple menu
Choose → Lock Screen.
Touch ID
On Macs with Touch ID, a short press of the Touch ID button locks the screen.
A hot corner
Open System Settings → Desktop & Dock → Hot Corners, pick a corner and choose Lock Screen. Push the pointer into that corner to lock.
Ask for the password immediately
In System Settings → Lock Screen, set Require password after screen saver begins or display is turned off to Immediately.
Make the lock screen useful
NotchMind, which I make, can show what’s playing, with synced lyrics, on your Mac’s lock screen, and play a sound when you lock and unlock. Notifications that arrive while it’s locked wait until you unlock. See music on the lock screen.
NotchMind