I disagree with the other answer that the objective is impossible on devices running a stock ROM, and that it cannot be achieved without root access.
For Samsung devices, Good Lock (available in Galaxy Store), an app from Samsung made available only in few countries, can do what you want. It runs on stock Galaxy devices and does not need root access. Here's what to do. Download Good Lock from the linked app store. Run Quickstar from the menu.
It is reasonably easy to follow it. If you are unable to follow it, then search Youtube for Good Lock. It should help out.
My experience with Sony devices I have ever had concludes that Sony devices don't support the feature you are after. I can't speak for other brands.