Do I need to have a free margin to lock positions in my trading account?
No, when you are trying to lock (hedge) a position, which typically involves opening an opposite trade to an existing one (e.g., buying and selling the same instrument), it would offset the margin of the existing one.
This can be referred for each product in product specification, "Margin hedge" – size of margin for hedged positions, which typically is 0.