I would like to lock the /etc/hosts file somehow in a way that only someone else can unlock it, possibly using a lock code.
I would then give the passcode to someone else.
I'm running Ubuntu 10.10.
Create an account for the other person and add it to the admin group (gives sudo access). Take yourself out of the admin group, so you can't use sudo.
As far as I know, Pass codes on files nearly always (well every time I have seen) uses third party software in order to encrypt the file.
I do not know of any software that will accomplish what you want as the file needs to be read normally by the OS. If you were to some how encrypt it, then someone else could always just delete it and recreate it.
What you want to do is to look in to standard file level protection and only give certain groups access to the file - such as Root/Administrators. You can read up about Linux permissions using