Run this command to open the file to edit. You will need the administrator password:
sudo nano /private/etc/hosts
Then arrow down and add your entry to the file. To save, hit Control+X and it will prompt to save changes, enter "Y" to save.