From Windows computers I’m used to write the apostrophe as AltGr+P on my localized keyboard (SLOVAK qwerty).
I achieved this by editing /usr/share/X11/xkb/symbols/sk and assigning apostrophe to the letter P.
This works.
But occasionally, after system update, this modified mapping is erased and reverted back to default.
How would I make this change more permanent?
That file is owned by a package so it will always be re-written when the package is updated.
You can copy the file and make your changes. If you call it sk_mine then use it like this setxkbmap sk_mine.
It’s temporary, see the link for making it permanent. Add to that, if the keyboard is external and is re-plugged then udev will override this, so you may need a udev rule to re-apply your custom map.
You could instead dump the current config using xkbcomp $DISPLAY ~/.xkbmap, edit that and then reapply using xkbcomp ~/.xkbmap $DISPLAY. Also temporary, and also needs a udev rule for external keyboards.
xmodmap works but is deprecated, and can’t do as much, though it should be fine for this. It’s definitely the best documented way/path of least resistance.
I haven’t used it much but AFAIK it would also need a udev rule for an external keyboard. However it may be automatically applied at login with some login managers (if you use a certain filename), with others it would need to be configured I think.