Note: I have the sense that the "canonical answer" that David is asking for with their bounty would involve some documented rule that specifically addresses the "melee attack at range" scenario. I'm not aware of any such rule, so I provide the following instead, expecting that it won't qualify for the bounty but will still provide a reasonable foundation for in-game rulings.
Does this mean that if the enemy can't see you (such as if you were in complete darkness), but they can see your spiritual weapon, you gain advantage to attack them with the spiritual weapon bonus-action attack?
No, it does not mean that.
In the spell description, we see three sentences, each of which have important and specific implications about how the spell works:
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.
- You create a weapon.
- You are making a melee attack.
- The target takes force damage.
Okay, I admit that last one isn't as important as the first two.
But the first two make clear that an actual weapon is being created, and that this weapon acts, effectively extending your own reach at a distance, in the capacity of a melee attack. This means that the attack comes from the weapon and not from your own person.
This is reinforced, though I admit not proven, by the fact that the damage is force damage. I.e. the weapon is itself causing the damage.
Since the weapon itself is what makes the attack, it is the visibility of the weapon that is relevant. The "you" in the reading of the visibility rules for attacks would be the weapon in this case. The caster is simply the marionettist, directing the movements of the weapon. But for the target to avoid the attack, they must respond to the weapon that is within melee range of them. As long as they can see the weapon, there is no advantage on the attack.
In other words, as a weapon that extends one's own reach, even when one's body is not visible to the target, the weapon one is wielding is visible to the target. So "you" are not actually entirely invisible. And the part of "you" that actually matters to the target is visible.
If one could somehow contrive to have the weapon not visible to the target — perhaps you are attacking through an opaque cloth that is obscuring the target's view of the weapon, but not your view of the target, or the weapon is within an area of Darkness while you can still see the target — then the Spiritual Weapon would have advantage.
Conversely, the caster's own visibility doesn't matter at all. The target is concerned with the thing that is attacking it, not the creature controlling that thing. The caster being invisible doesn't obscure the threat that exists within melee range of the target, nor is there anything that the caster might do themselves that would in any way affect the target's perception of the attack, whether to their advantage or disadvantage.