https://forum.xda-developers.com/t/guide-relocking-bootloader-on-custom-roms.3927450/
Tl,dr: Yes it is, but your ROM and recovery must be signed.
Welcome to the droidymcdroidface-iest, Lemmyest (Lemmiest), test, bestest, phoniest, pluckiest, snarkiest, and spiciest Android community on Lemmy (Do not respond)! Here you can participate in amazing discussions and events relating to all things Android.
The rules for posting and commenting, besides the rules defined here for lemmy.world, are as follows:
1. All posts must be relevant to Android devices/operating system.
2. Posts cannot be illegal or NSFW material.
3. No spam, self promotion, or upvote farming. Sources engaging in these behavior will be added to the Blacklist.
4. Non-whitelisted bots will be banned.
5. Engage respectfully: Harassment, flamebaiting, bad faith engagement, or agenda posting will result in your posts being removed. Excessive violations will result in temporary or permanent ban, depending on severity.
6. Memes are not allowed to be posts, but are allowed in the comments.
7. Posts from clickbait sources are heavily discouraged. Please de-clickbait titles if it needs to be submitted.
8. Submission statements of any length composed of your own thoughts inside the post text field are mandatory for any microblog posts, and are optional but recommended for article/image/video posts.
Community Resources:
We are Android girls*,
In our Lemmy.world.
The back is plastic,
It's fantastic.
*Well, not just girls: people of all gender identities are welcomed here.
Our Partner Communities:
https://forum.xda-developers.com/t/guide-relocking-bootloader-on-custom-roms.3927450/
Tl,dr: Yes it is, but your ROM and recovery must be signed.
I tried these commands before, and I encountered red flashes and my phone was unusable. I went back to original ROM.
No. While it is in theory possible if you sign the image, it's not worth the risk. If you relock the bootloader on a Xiaomi device and the image isn't signed (and it most likely wont be) the phone is done for. Relocking gives basically no advantages that can't be fixed through a root module.
One exception I have seen so far are the UBS banking apps - even with tools like LSposed, HideMyApplist, and Shamiko, the UBS apps still refuse to run. Other banking apps / other apps I use don't have this stubbornness.