Below is some ways of how to lock macbook screen without logging out.
First, we need to enable a log-in password. Go to system preferences > Security & Privacy and check the box of Require after sleep or screen saver begins. You can set timing of the password from immediately to up to 8 hours.
Close the lid. With closing the lid, you need to enter your password to log back in.
Apple icon in menu bar. Click the Apple icon in the upper-left corner and choose Sleep so you need to enter your password to log back in.
How to lock macbook screen without logging out with keyboard shortcut
Keyboard shortcut, with pressing Cmd-Shift-Power to lock your MacBook. Or Cmd-Option-Power to put Macbook to sleep.
Hot corners, You go to system preferences > Desktop & Screen Saver and click the Hot Corners button. Choose put display to sleep or start screen saver for one of the corners you place your cursor.
You can add an icon to your menu bar to lock your MacBook.
Open the Utilities folder in your Applications folder.
Open Keychain Access.
Go to Keychain Access > Preferences.
Check the box for Show keychain status in menu bar.