If a fresh sell order is placed in a scrip/contract where there is already a buy position, will it be allowed and treated as the square off leg? Or is it mandatory to place the square off order from the existing position?

A contra order placed using MIS for the open position in MIS will be considered as the square off order. However, you can possibly create a contra order by using another facility (non MIS) as Order Type.