Change camera from rectangle to square by center
The camera property Sensor Size is a measurement in the largest camera dimension. Therefore, to keep the same scaling, if you change the largest dimension (in this case, reducing from 1920 to 1080 leads to a reduction to 56.25%) to match the smaller dimension (eg, 1080) you simply need to adjust the Sensor Size to match te reduction in the maximum dimension.

Therefore, for default render dimensions of 1920x1080 changed to square 1080x1080, the largest dimension is reduced to 56.25% of its original size (1080/1920 = 0.5625) - so to keep the same scaling the Sensor Size of 32 should be similarly reduced as 0.5625 x 32 = 18.