To configure a pin in output or input there is the "pinMode" function .
To configure the pin level (in case of output) , there is the "digitalWrite" function,
But is there a function to configure the pin in open drain or push pull ?
Using the search feature on this site, one can come up with several thingies like this one a thingy about open drain. Also, you can do an internet search on the words "arduino gpio open drain". That way you won't have to wait for someone else to do it for you.
Only if the processor supports it. On the AVR-based Arduinos (UNO, Nano, Mini, Mega, Leonardo, Micro...) the outputs are all Push-Pull. You can use an external N-Channel MOSFET to convert the output to Open Drain or an NPN transistor to convert the output to Open Collector.
You can SIMULATE an Open Drain output by using: pinMode(pin, OUTPUT); digitalWrite(pin, LOW);
for LOW and: pinMode(pin, INPUT);
for High Impedance.
Well not quite. The AVR pins support pseudo-open-drain as you explain (ie the pin still has a protection diode to the Vcc rail, but is driven only by the low-side FET):
The fact there is a protection diode still connected is nothing to do with push-pull v. open drain per se - you can have open-drain with a protection diode and still implement wired-AND busses using it.
To do level shifting to a higher voltage requires that there be no protection diode, and that the output FET is high-voltage rated. This is the full open drain / open collector arrangement, but many logic chips have open-drain pins that are not high-voltage.