As you say, AS path prepending uses the as-local-count configuration to set the local prepending setting. As such, when you set this it is fixed on that platform so you have to use something to change it when the state changes. As with all things F5 there are multiple ways to do that - you can do it it via a script which is run by alertd ( configure user_alert.conf ), you can do it by iCall or you can create yourself a script which runs as a daemon.
If it were me, i'd do it by either iCall or alertd depending on whether you have experience with iCall, tmsh scripts etc. You may find that iCall is more robust ie a periodic script which checks if device is active and sets the parameter appropriately