How to prevent any Linux package installer and its sub processes to modify, append the ~/.bashrc, or any certain file else, which must remain normally able to be used, edited etc freely by the login user ?
Try to set immutable attribute (chattr +i), and see if the shell complains at next login.
To edit it later you will have to unset that attribute with -i
AFAIK there is no other easy way apart maybe from complex apparmor/selinux/maybe polkit rules which few use so it's little documented.
Or copy ~/.bashrc to ~/.mybashrc (or similar)
edit ~/bash_profile to point at the copy
[[ -f ~/.mybashrc ]] && . ~/.mybashrc
Then if you have issues in the future where things don't work you can refer to ~/.bashrc to see what a package is expecting in the PATH or environment variables etc.