The other answers do a good job of addressing general cases, but since neither of them give specifics on the cases you ask for, here are some answers to your specific questions:
An ally of the rogue has the Sanctuary spell up and is within 5 feet of the enemy. The Sanctuary spell continues as long as the warded ally does not attack or casts an attack spell (and maintains concentration). Assuming the warded ally does not attack, would it be considered an enemy for enabling the rogue's sneak attack?
The warded ally could always change their mind and attack, breaking the spell. It is perfectly reasonable to think this situation qualifies as an "ally of the rogue" that is in some way distracting the enemy. They could choose to take an attack of opportunity should the enemy run, for example. It'd break Sanctuary, yes, but the enemy can't know whether the ally will choose to attack or not. I don't see anything RAW that prevents this; neither do I see a consistent interpretation of the rules that prevents this.
An ally of the rogue has Gaseous Form active and is within 5 feet of the enemy. Gaseous Form does not allow the ally to attack. Does this enable sneak attack?
This one is a bit trickier; since the target of the spell cannot take attacks of opportunity, I could see DMs ruling either way. However, do consider that the spellcaster could stop concentrating on the spell, thus allowing the target of the spell to attack again. The spell doesn't seem to prevent the target of the spell from aiding an attack, so I would say this falls into the same precedent as a familiar counting as an ally for sneak attack (see Crazjtk's comment, also this discussion on Reddit: https://www.reddit.com/r/dndnext/comments/49h83w/regarding_sneak_attack_feature_can_a_familiar_be/). So it seems that per RAW this works for sneak attack; this certainly would meet the minimum threshold of distracted by an ally of the rogue. If that cloud next to you could materialize at any moment into a wizard, I think you'd be distracted too.
What if the ally is a warlock with Cloak of Flies active and damaging the enemy?
Most definitely yes; the warlock is within 5ft of the enemy at this point, and (assuming that the warlock is a fellow PC or other ally of the rogue) is no different than having any other ally next to the enemy. Cloak of Flies doesn't prevent you from attacking, or enemies from seeing you. Even if the warlock didn't have weapons, the warlock could still punch the enemy. Punches hurt too.