To sell an option against a long option already in a margin type account simply create a sell order and if the account has enough available funds to meet any change in the account's margin requirements the order is accepted. The short option will automatically be margined with other options on the same underlying.
In terms of selling the same option contract IBKR does not allow clients to simultaneously maintain both a long and short position in a given instrument in the same account and all positions are netted.