It probably would, by just keeping the sun from beating on the roof, but it would need something breathable between the roof and the carpet. I think that if the carpet were to get wet (rain, humidity), it would just set up an ideal condition for mold, mildew, etc. to accumulate. That would NOT be good for the roof.
I think a heavyweight tarp with some support system underneath would be just as effective, and much less heavy under wet conditions.
2017 Ford F350 Crew Cab 6.7L 4x4 DRW