Moise Kean set the Turin giants on their way with an early strike before US winger Timothy Weah doubled the advantage with his first goal for Juve after signing for them earlier in the summer.
Vinicius Jr. pulled one back for the Spanish giants only for Dušan Vlahović to seal victory for Juve.
Vlahovic has been at the centre of speculation he could be involved in a swap deal with Chelsea for Belgium forward Romelu Lukaku.
Juventus will miss out of European football next season due to a ban over financial irregularities.
“We've ended this initial period of work well against a very good side, which has great technique and equally great physicality,” said coach Massimiliano Allegri.
ANSA