The Hopf–Lax formula in Carnot groups: a control theoretic approach