I just did that last week with my 12-year-old son on a 3-day, 29-mile trip. He loves potato gnocci with pesto and we have some pretty serious basil in 6 windows boxes on the inside windowsills. It's really more of a 9-foot basil hedge in mid-summer.
A number of options:
Vac-pack it if you have the equipment (as Alaskans harvesting berries, sockeye, halibut, we obviously do). Then freeze. If making mega-batches, use ice-cube trays to make dozens of pesto cubes at a time, freeze them, pop them out, place in ziplocks, and store in the freezer for a year or more.
Use a recycled "disposible" water bottle. 12-ounce and 16-ounce sizes are readily avaiable. The cheapest ones (that come in a 24-bottle case) are a little thin for something as oily as pesto, I'd go for name-brand Aquafina or Dasini bottles which are a little tougher. I've also gotten little 8-ounce water bottles in First Class on the plane numerous times and save those to solve too-big/too-small dilemnas. Once you've used the pesto from the bottle, crush it and replace the lid to keep its volume down.
Freezer-weight zip-lock bags are fine IF you protect them inside of something else - a bowl or pot, for instance. Dump most of it in the pasta pot, invert the bag and use it like a glove to (1) stir the pesto into the pasta by hand and (2) wipe as much pesto from the bag as possible.
*IF* you haven't used DEET on it, a mosquito headnet makes a very lightweight pasts strainer. Just use campsuds later to wash the starch off it. If you don't have a strainer, improvise OVER A BOWL so you can recover any escaped pasta.
For store-bought pesto, I just bring it in the little 6-ounce plastic tub it comes in. Depending on your camp gear, one person could use that tub as their eating bowl, although our practice is to eat it communually out of the cooking pot.
Store bought or home-made, I freeze it before the trip and pack it and other temperature-sensitive food inside a sweater or sleeping bag. Sometimes I freeze that stuff sack a few days in advance. If you do that, will still be cold 18-36 hours later. Even if you don't, you reduce its time at elevated temps by many hours and it is fresher when you use it.
When freezing pesto, its volume changes very little (unlike water which expands). The water component gets bigger on freezing, but the oil gets smaller. On balance, it expands/contracts very, very little.
Pesto and gnocci aren't UL, but if you do that your first night or two, you don't carry it far and your pound-miles are reduced.