For example put it into: /etc/pacman.d/hooks/spotx.hook
Tested with spotx-git + spotify AUR packages.
This hook will re-run spotx after every Spotify or SpotX update (both of which warrant it, as Spotify will override the files to stock, and updated SpotX might fix bugs or add support for new Spotify versions).
The -f flag has to be used, since otherwise the script will exit with an error after SpotX was updated, but Spotify was not, the error informing you that the patch was already performed. The -f flag will cause the SpotX script to firstly restore the backup that it has previously made, and only then apply the patch, ensuring that the patches apply cleanly on the current version once again.
Target = spotx-git is needed, since the spotx-git package providing spotx is not enough to trigger the hook (it's not considered a target). The Depends = spotx on the other hand is fine.
Note that a hook like this only makes sense if both SpotX and Spotify are installed by pacman. If you're using the spotify-launcher package or another means of installation such as Flatpak, the hook will not trigger when those upgrade and override the Spotify binaries. Quite obviously.