I know that I have to edit the /system/etc/hosts to map an IP address to a host name, but it seems that I can't edit the file. Is it because my android phone is not rooted?
Kindly advise. Thanks.
You can use the following guide and application to setup rules for specific domains.
Hit sync rule before leaving to make sure the file is downloaded.
Tap and activate the mode you wish to be in, You can activate more than one at a time so be careful as this will override one or the other.
Source: https://silocitylabs.com/post/2018/03/02/changing-dns-settings-for-android-development/