The VANDELS survey: The relation between the UV continuum slope and stellar metallicity in star-forming galaxies at z ∼ 3