Issue with communication between arduino mega and nodemcu esp 8266

You should not be using SoftwareSerial with a Mega - you should use one of its 3 hardware UARTs.

Serial1.print("1");
for instance
will send the character for the numeral '1'.

Your ESP sketch, for now, should be reduced to turning on an LED when a "1" is Serial.read.
I believe the 8266 is SoftwareSerial-capable.