I am asking this question for a strategy in Pokémon Showdown! (Gen 8 Anything Goes). BTW, not Fairy Lock.
G-Max Sandblast inflicts damage to a target and binds the target for four to five turns. This binding effect is similar to Sand Tomb, except that it doesn't end prematurely if the user switches out or faints. G-Max Centiferno inflicts damage and binds the target for four to five turns. This binding effect is similar to Fire Spin, except that it doesn't end prematurely if the user switches out or faints.
G-Max Sandblast inflicts damage to a target and binds the target for four to five turns. This binding effect is similar to Sand Tomb, except that it doesn't end prematurely if the user switches out or faints.
G-Max Centiferno inflicts damage and binds the target for four to five turns. This binding effect is similar to Fire Spin, except that it doesn't end prematurely if the user switches out or faints.
Source Source
Trapping is also still retained if you switch out using Baton Pass. G-Max Terror's trapping efect, however ends when you switch out the Pokemon which used it.
Replay for proof. Apart from the mentioned Fairy Lock, the two G-Max moves along with trapping move with Baton Pass are the only one whose trapping effect is retained after switching.
Bulbapedia's list of trapping moves for reference