Sudo doesn’t automatically allow you to change any file. Read-only files stay read-only, and some editors temporarily add write permission when used as root.
Files that are interfaces to kernel objects can report permission denied if the command you’re trying to write is not possible. So in this case the file path matters a lot.