A characterization of the value function for a class of degenerate control problems