Depending on the nature of your modification, instead of modifying it in place, you can copy the file and put it somewhere else that will override the original file. This may cause other issues, however. For instance, if the original file is updated to fix bugs, your modified copy won't get those updates.
For instance, if you just want to modify the desktop file or the icon, you could copy the desktop file to ~/.local/share/applications/
and then modify that copy, change the icon path in that file, etc.
Many applications install config files in /usr/
or /lib/
and, depending on the application, you may be able to modify a version of the config file in your home directory, or copy it to a parallel path in /etc/
which should not get overwritten.
If the modified file is in the /bin/
directory of the application, you may be able to copy it to ~/bin/
and make sure that directory is before the application's bin directory.
If the file is a core part of the application, there may not be a clean way to make the change in a way that doesn't get overwritten. Your only choice is to either re-patch the file on updates or freeze that application from being updated.