Remember: MetaMask isn't like a traditional website, where you're logging in to a remote server. Rather, MetaMask stores your Secret Recovery Phrase, private keys, and a certain amount of information about how you use MetaMask (the 'state logs') on your local device, so that whenever you want to carry out an operation on a blockchain, your SRP and private keys are ready to be used.
In this sense, you don't log out of MetaMask, but you can lock the application, so that you'll have to re-enter your password or biometrics to log back in.
Click Lock in the dropdown when clicking on the identicon icon:
You can also set an auto-lock, which you can find in Settings > Advanced:
Here you can set a timer in minutes after which the wallet will be locked.
You will see Lock at the bottom of the sidebar. Tapping it will prompt a confirmation message to lock the wallet
Please note: you can also add an extra layer of security by adding a hardware wallet. Refer to this article on hardware wallet integration.