I’m a sabermetric dork, but I’m not a true expert on WAR. With that disclaimer, I think the answer is it depends on the method of calculation.
Fangraphs WAR: The groundball pitcher would be penalized, because it’s based on FIP...and so some non-zero number of those ground balls “should” be hits. This is obviously a contrived example but the 27 K pitcher would have a FIP of 0 as the basis for his WAR calculation, while the 27 GB guy would have 3.20. And so the strike out guy individually contributed more toward saving those runs (relied on the defense less).
Baseball Reference WAR: Less obvious to me, but it’s intentionally designed to be a more descriptive stat so is based on actual runs allowed as the starting point and not FIP. So, I THINK in this case the two WARs would be equal (unless I’m missing a 2nd order defensive component in the calculation that would similarly adjust being perfect on balls in play).