Using the optional rules on flanking in the DMG on page 251, would a caster who gains access to the Spiritual Weapon spell be able to use said weapon to trigger the advantage from flanking?
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.