Setting GPIO pin in/out without editing system files

I know it would be easy to add something like "gpio -g mode 27 out" manually so it runs on system startup, but is there a plugin, or otherwise a way Octoprint can run commands at startup? My main concern is that I want to do it in a way fully compatible with Octoprit, so things won't mysteriously stop working someday after an update or after recovering from a backup. Thanks.

You can achieve this with script files and event subscription commands with a type of system I think, documented here. There are also GPIO related plugins that you may also be able to use.

Unless you find a way of doing it with an Octoprint plugin you will always need scripts that are installed on the system outside Octoprint. That means you need a way of restoring those scripts and settings. If you are thinking of an Octoprint update, scripts installed in the /home/pi won't disappear after an update or Octoprint backup recovery. But they will disappear if you build a new instance on a new memory card.
I develop, test and keep script sources [OK designs, STL's GCODE, everything] on a NAS on my local network, then copy / install / configure on each Pi.
If you don't want to lose scripts, and occasionally your microSD card WILL die, get your system up and configured, then shutdown and make a complete image backup of the card by putting it into another computer. If you are using Linux, the command looks like 'sudo dd bs=512 if=/dev/sdb of=/home/putyourusernamehere/image_backup.img' If the card automounts when you install, you'll need to unmount the partitions first.
As I can rebuild an Octoprint instance, scripted, the only thing I SHOULD backup is the Print History, when I get around to using OctoFarm properly I won't need to do that either.
Code installed outside Octoprint will be safe, because Octoprint and its installation scripts and systems won't know about a new directory you create in /home/pi. I have /home/pi/utils and keep scripts in there which can be run by cron or systemd startups.