Below are the steps I followed on my Windows machine on Windows Terminal:
Run the following command to know your AVDs:
emulator -list-avds

Run the following command to open the emulator for writable mode:
emulator -avd Pixel_XL_API_29 -writable-system -no-snapshot-load
Replace Pixel_XL_API_29 with your AVD name.

Ignore the warnings there.
In a new Terminal tab run the following commands:
- adb root
- adb shell avbctl disable-verification
- adb reboot

Wait for your emulator to reboot. It can take upto 1 minute.

When the emulator is rebooted, run the following commands:
You will get a remount succeeded message after that:

Now is the time to push our host file from Windows machine to Android's emulator
adb push D:\hosts /system/etc/
D:\hosts is the location of the hosts file present at the D drive of my Windows machine.
/system/etc/ is the location in Android's emulator where we want to copy that file.
After successfull operation you will see a message like this:

To verify that the hosts file has been pushed you can run the following commands:
- adb shell
- cd system
- cd etc
- cat hosts
You will see the contents of hosts file in the Terminal:
