Then you'll need to buy a new one, you can't just unplug the microcontroller IC from the Mega. If you're on a tight budget then somewhere like Aliexpress is going to be your friend- you can find compatible boards for fairly cheap.

Replacing the ATmega2560 microcontroller on the Arduino Mega requires some fairly advanced soldering skills. After replacing it, you will also need to flash it with a bootloader, which requires you to own an ISP programmer or another Arduino board turned into an "Arduino as ISP" programmer. Once you add up the expense of the replacement chip and the programmer, plus the time you spend on the replacement and the chance that other components on the board are also damaged, or that you will fail in the repair effort, you may find that the best choice is to buy a new Arduino board and get on with your Arduino journey.

As a beginner, you might be better off to start with a cheaper board like the Arduino Nano, Uno, or Pro Mini so the inevitable mistake won't be so expensive next time. If you get the version of the Uno with the DIP ATmega328P, you do have the option of easily popping out the ATmega328P and replacing it if it's ever damaged. On the other hand, there are other chips on the Uno which could also get damaged and replacing those won't be so easy.

With the Pro Mini, you use a separate USB to serial adapter. That means if you damage the Pro Mini, you may be able to still use the USB to serial adapter, or vice versa. It also means that you can share one USB to serial adapter between multiple Pro Minis to save money. If you get a Pro Mini, make sure to buy a USB to serial adapter that has the correct pinout so it can be plugged directly into the Pro Mini, rather than requiring a mess of jumper wires:

DTR or RTS

RX

TX

VCC

CTS

GND

Once you have gotten a bit more experience and are a bit less likely to burn up boards, you can start playing with the more expensive boards like the Mega.

Always do wiring with no power connected. Then before you connect power, take some time to think carefully about the circuit and triple check all the wiring.

But I also think it's important to feel free to experiment and make some mistakes along the way. That's why it's nice to use lower priced boards, where you don't have to feel so afraid of "magic smoke" incidents. It is unfortunate to have to replace hardware when you don't have much money to spend on Arduino, but the knowledge you are gaining is extremely valuable. Even mistakes can teach you a lot, especially if you take some time to think "what went wrong?", "what can I do to avoid this next time?". Not so many years ago, you would have had to spend many thousands of dollars on hardware, tools, software, and university courses to learn how to use microcontrollers. Now, you can go a very long way by only spending a few dollars to buy an Arduino board with some basic supplies and tools. The hardware is so much cheaper, high quality software is free, and there is a tremendous amount of free information on the Internet.