Is there any trick to make a palindrome-cocktail?
You could, of course, create gel layers, and the determining factor in stability would be the firmness of those gels. However - and I suppose this is just a hunch - I seriously doubt that a gel firm enough to hold the weight of all the heavier layers above it (and you are asking for at least 3) would really be drinkable, unless you're aiming for the consistency of a "Jello shot".

A better idea, in my opinion, would be to simply change the densities of certain layers, and an effective (and tasty) way to do that is with sugar, or more accurately, sugar syrup. There's a type of syrup used in bartending called Gomme Syrup, which is a thick sugar syrup with Gum Arabic added to prevent crystallization (among other things).

Sugar, by itself, has very poor solubility in alcohol, but sugar syrups and gomme syrup in particular will have few problems, considering that's already how many mixed drinks are made (like Whiskey Sour). If you're feeling really adventurous, you could also use sugar alcohols such as sorbitol or xylitol, which dissolve readily in ethyl alcohol in solid form. However, these are much more potent (sweetness-wise) than sucrose and some people report gastrointestinal reactions, so use at your own risk.

Sugar syrups are very dense, so if you mix them thoroughly with a particular spirit, you'll end up with a heavier (and sweeter) version of that spirit. So to make your palindrome, start with what you'd normally put at the top (say GM for the B52), mix it with syrup (it shouldn't take an excessive amount - maybe 20-30% by volume, but you'll have to experiment), and layer that on the bottom. Then take the next-lightest, mix it with slightly less syrup, and continue. Once you reach what would normally be the densest liquid, layer the drink as normal up to the top with the "pure" spirits.

The more layers, the more math you'll have to do, because you'll need to make sure that you add just enough syrup to layer 2 so that it's lighter than layer 1 (bottom) but still heavier than layer 3, and so on. Unless you're prepared to make the drink very sweet, you'll need to be fairly precise in your calculations.

Disclaimer: I haven't yet tried this myself, as it's the first I've heard of anyone trying to do this. However, I see no reason why it wouldn't work with proper (careful) layering technique. In fact, I remember doing something very similar all the way back in primary school, called rainbow in a glass.