In theory a macro like this should backstab when unstealthed and no dance and Ambush otherwise.
#showtooltip Ambush
/use [stance:1/2/3]Ambush
/use [stance:0]Backstab
However, I found that it sometimes randomly decides to not do that. It can happen at any point of the shadow dance that I just backstab, so I have to go back to use a Stealth Bar. I threw my steath bar away when I switched to ElvUi. I found that we have up to bar 10 that we can switch to, so in therory I can have for every of my 5 bars I use a seperate stealth bar.
Wanted to share that the macro is kinda broken if somebody else happens to use one of these.