How to use ESP8266 library with Arduino Mega

Is it possible to use ESP8266 library with Arduino Mega to control my ESP8266 module and implement WifiClientSecure class to connect 443 https port? I have been using ESP8266 library ( with Arduino Uno to control my ESP8266 module but i am not sure wether it will be as easy as Arduino uno or not? Thanks for your attention. I’m looking forward to your reply.

That's not a library. It's a boards support package that's used for directly programming the ESP8266. You definitely haven't been using it with the Uno unless you're just using the Uno as a USB-serial adapter to program your ESP8266, in which case a Mega would provide absolutely no benefit over an Uno. You can't use it with Mega or Uno because those use different microcontroller chips: AVR not ESP8266.

How did you use it? the esp8266 arduino core you linked is for esp8266 sketches. Do you have two sketches, one for the esp8266 and second for the Uno and they communicate over serial with SoftwareSerial on the Uno side? Then in Mega you will use one of the hardware serial ports (Serial3 for example) and not SoftwareSerial.