Can not initialize ESP module in Arduino SoftwareSerial
#ifndef HAVE_HWSERIAL1
#include "SoftwareSerial.h"
SoftwareSerial Serial1(11,12); // RX, TX
#endif


Because your Mega has a Hardware Serial1 port, HAVE_HWSERIAL1 is defined. Thus the lines inside that preprocessor conditional will not be compiled. This means you should connect the ESP8266 to the Serial1 lines on your Mega:

Mega | ESP8266
--------------
19   | TX
18   | RX