I there a way to set a separate password for a file (other than root)? I struggle with procrastination on sites like reddit, youtube, and netflix so I want to block them. I know I can do this by modifying /etc/hosts to redirect to 127.0.0.1, but I still can and do change the hosts file back. Is there some way I can set a password for /etc/hosts so that I can not sudo edit it? Alternatively can someone recommend a better solution to block these sites? I use High Sierra and Chrome.

Thanks for your help.
What you wish to achieve sounds like a duplicate of this question. There are complications such as SIP to consider these days. More trouble than it's worth.

It would be more effective to 'firewall' those sites in some way that does not rely on a password that you may forget, or be tempted to revert when you should be concentrating your attentions elsewhere. Fortunately, as the other question stated, there's an app (or many) to do that.

I personally used Self Control some years ago when trying to get coursework done. It's free. There are other similar apps out there, some paid-for for the sake of extra features, though I feel those extra features are just another avenue of procrastination.