This video shiws how to root the Andoirs emulator using the Macbook Pro M2/M1 Chip . this will work in other Linux OS too.
Some steps in the Video:
1) git clone https://github.com/newbit1/rootAVD.git
2) cd rootAVD
3) ./rootAVD.sh run in terminal
4) run ./rootAVD.sh system-images/android-32/google_apis/arm64-v8a/ramdisk.img
make sure it "android-32" match with your android API like android-30 or android-34
rest follow the video