When you join The Legion you also take A oath.
"Upon my honor I do swear undying loyalty to the Emperor Titus Mede II, and unwavering obedience to the officers of his great Empire. May those above judge me, and those below take me, if I fail in my duty.Long live the Emperor! Long live the Empire!"
But what if he's dead? You take an oath to serve a dead emperor? Unwavering obedience to the officers of his great Empire? Oh I guess it's no worse than the other side's oath. Although my true oath is to Sithis. If the Night Mother said to kill Ulfric, I'd do it without hesitation. Maybe with a bit more style than I did with Mede II. Like ask for an audience and issue a challenge, even though Sonja is fighting for him now.
But alas, Empires are rife with treachery. Just look back in history. It is better to be the Listener than to be Emperor.