1 Answer
1

By RAW: No, it wouldn't help with flanking.

The flanking rules require that two creatures (specifically allies) are on opposite sides of the creature they flank.

When a creature and at
least one of its allies are adjacent to an enemy and on
opposite sides or corners of the enemy's space, they
flank that enemy [...]

However, a spiritual weapon does not count as a creature or an ally of any other creature, it is simply a floating weapon. It does not occupy space and cannot be attacked.

You create a floating, spectral weapon within range that
lasts for the duration or until you cast this spell again.
When you cast the spell, you can make a melee spell
attack against a creature within 5 feet of the weapon. On
a hit, the target takes force damage equal to 1d8 + your
spellcasting ability modifier.

Additionally, it was confirmed by Jeremy Crawford that Spiritual Weapon does not count as another enemy for sneak attack, which is nearly the same condition.

While many DMs may quite reasonably rule that a floating, spectral weapon would be a sufficient condition to provide advantage, by RAW it does not.

\$\begingroup\$How do you determine it's not an ally? That's not a defined mechanical term and there are lots of ways a sufficiently creative player could create a character's worldview such that they think of said weapon as an ally.\$\endgroup\$
– Please stop being evilJan 14 '19 at 23:42

\$\begingroup\$You are correct that the term "ally" is not strictly defined in 5e. And I agree that your DM could very reasonably allow it to be used as an ally for flanking. However, 5e uses the English definition of "ally", and a weapon does not constitute a "A person or organization that cooperates with or helps another in a particular activity." (See: What does 'ally' mean, as a game term?) Furthermore, if a Spiritual Weapon does not count as an enemy for sneak attack, then it can hardly be an ally for flanking.\$\endgroup\$
– the_moooonJan 15 '19 at 1:21