Carvajal sustained the damage during Los Blancos' Champions League final against Liverpool last month, restricting him to just 37 minutes of his side's 3-1 win in Kiev.
The 26-year-old was still named in Spain's 23-man squad for Russia 2018, though, and Lopetegui expects to have the defender available for selection as early as the June 25 showdown against Morocco.
"You have to hold him back slightly, but I'm sure he'll be ready," he told reporters. "You want him to take two steps forward instead of just one before suffering a setback.
"I don't know if he'll be ready for the first or second match, but he'll be fine."
Sergio Busquets is expected to recover from illness to feature in Spain's final pre-World Cup friendly against Tunisia on Saturday.