Here is a step by step solution:
Download the free TextWrangler app ( http://www.barebones.com/products/TextWrangler/ )
Create a .profile file in your home folder if it does not exist
$ touch ~/.profile
$ open -e ~/.profile
Edit the file and give it the following aliases, along with any others you may wish to add:
alias edit_hosts='sudo open -a /Applications/TextWrangler.app/Contents/MacOS/TextWrangler /etc/hosts'
alias edit_vhosts='sudo open -a /Applications/TextWrangler.app/Contents/MacOS/TextWrangler /etc/apache2/extra/httpd-vhosts.conf'
alias edit_httpd='sudo open -a /Applications/TextWrangler.app/Contents/MacOS/TextWrangler /etc/apache2/httpd.conf'
alias edit_alias='open -a /Applications/TextWrangler.app/Contents/MacOS/TextWrangler ~/.profile'
alias reload_alias='. ~/.profile'
Save the file and run:
$ reload_alias
Now when you run edit_hosts or the other edit_* aliases, the TextWrangler app should open the hosts file. It will still be locked, but this application can unlock it once you start editing, it will prompt you. You now have a one-line command to edit the root owned files of your choice.
You can also alias just the first part of the path:
alias edit='sudo open -a /Applications/TextWrangler.app/Contents/MacOS/TextWrangler'
which will let you execute commands such as
$ edit /etc/hosts
and still achieve the same results.
Edit: other answer looks to be a better solution as it does not require the download and installation of another application.