Can a Peru passport holder flying from Peru to Cancun, Mexico take a flight with a plane change in the US.? International travel
Yes, provided you have a current US visa.
Peru does not participate in the Visa Waiver Program so a visa is required to enter the United States. This is the case for all connections as no US airport has a transit zone.
Note, the visa refusal rate for Peru is quite low, ~20%. Whether or not it's worth applying is something only you can determine.