Alexander Zverev won the Madrid Masters for the second time as he defeated Matteo Berrettini in three sets.