How to lock screen ratio? Unity2d

You can letterbox your game presentation.

There are even assets on the asset store for this but I have not tried any personally.

One easy way is to use two layered cameras, one for the main area of your game, the other to fill in the letterboxing.

Another way involves using UI, if your game uses UI, and the AspectRatioFitter and other layout tools.

Beware that certain walled-garden platforms may reject your submission if you letterbox with blackness. This is the case with Google Android TV for instance, and may be the case for others. Read the individual technical requirements for the platform(s) you target to see if there may be something more you need to do beyond letterboxing.

Here are some notes on UI Anchoring, Scaling, CanvasScaler, etc: