I have a rooted device. I would like to protect my hosts file from being deleted, maybe with a password or something like that. Is this possible?
As is currently stated (revision 4), the answer is No.
Your hosts file is located at
/system/etc/hosts, in a filesystem of (probably) ext4. Since ext4 uses regular Unix permissions and Android does not support ACL, you have no chance to do so.
However, I don't think you really should protect it as it's protected by default, because
/system is mounted as read-only by default. As long as you don't grant your root access to malicious apps, no one will delete your hosts file.
Moreover, there are alternative dirty approaches but I don't think they're much helpful so I'm not posting them here.