Triggering ESP32 and Optocoupler together

Hi high_impact. Welcome to the forum!

No quite sure what you mean by this as ground is generally common? Perhaps you could provide a wiring diagram of what you intend to do? It can be a photo of a hand drawn diagram.

If you mean to drive the relay then NO! Do not wire GPIO pins direct to a relay drive coil. Driving a relay requires back EMF protection using a diode. In addition, the current from the GPIO is unlikely to be anywhere near enough to drive the relay and will result in a fried GPIO, and possibly further damage to the MCU. You will will need a drive transistor, FET, or a driver/controller board.