Best way to connect 5V to GND from ESP (3.3V) - transistor or optocoupler?
could I use BC547 (NPN) transistors for that purpose  


Yes.  

These are not meant to be for really high speed switching (greater than a few 100 KHz) but will work assuming the joystick signal rate will be slower.  







simulate this circuit &ndash; Schematic created using CircuitLab