Assuming that this means an ESP-01 then there are quite a few different tutorials on the forum. It’s actually pretty easy, once you work out the wiring. Just make sure you don’t connect it to the Tx/Rx pins on your Mega, as these are Serial0, which you’ll use for debugging. Use one of the other hardware serial ports.
Pete.