How to define a microcontroller pin as open collector or open drain?
Whether an output is an open drain or open collector or something else is a question of hardware design.  

An open collector output has to be built so that the output pin is connected to the collector of a transistor of the chip - and the collector is connected to nothing else.

If a chip isn't designed with an open collector output, the no amount of configuration will get you one.

That said, many microcontrollers are designed to have switchable GPIO pins.  You can configure a pin to be input or output, and you can configure what type of output.

What combinations are possible depends on what the hardware manufacturer decided to build into the hardware.