How do I make a file permanently read-only on Linux so even root can not edit it?
There is an "immutable" bit for files.
Programs (even running as root) won't be able to tamper with the file. Of course, root can un-do the bit, but most programs (especially non-malicious ones) won't get past it.
Set it with
sudo chattr +i file
you should have root perms
sudo chattr +i file