This does not work.
As of the November 10th, 2020 errata to the Sword Coast Adventurer's Guide, the green-flame blade cantrip (SCAG, p. 142; TCoE, p. 107) has a range of "Self (5-foot radius)".
However, the third benefit of the War Caster feat says (PHB, p. 170; emphasis mine):
When a hostile creature's movement provokes an opportunity attack from you, you can use your reaction to cast a spell at the creature, rather than making an opportunity attack. The spell must have a casting time of 1 action and must target only that creature.
Since green-flame blade has a range of self, it targets the caster, not "only that creature" which provoked the opportunity attack.
It should be noted that rules designer Jeremy Crawford has stated on Twitter than War Caster still works with booming blade, so it should still work herestated on Twitter that War Caster still works with green-flame blade. I disagree that the rules clearly lend themselves towith this interpretationruling, based on my explanation above, and think he should have made his rules clear enough to not need unofficial rulings on Twitter.