The 29-year-old Briton replaces Germany's Adrian Sutil in the role as back-up to race drivers Felipe Massa and Valtteri Bottas.
Di Resta raced for three seasons in Formula One with the Force India team between 2011 and 2013 with a best result of fourth place.
"It will be a busy year combining both driving in DTM (German Touring Cars) with Mercedes AMG, and attending the Formula One Grands Prix in my new reserve driver role," said the Scot in a statement.
News that makes sense
Your trusted source for staying up-to-date with the world around you. Get free daily news updates and analysis, straight to your inbox.
"I will be giving my full support to both and look forward to the exciting possibilities the year has ahead."
Mercedes-powered Williams finished third overall last season.
(Reporting by Alan Baldwin, editing by Patrick Johnston)
