Melt 2 tablespoons of the butter in a large skillet over medium heat. Add the onion, salt & pepper (½ teaspoon each) and cook, stirring occasionally, until soft (about 15 minutes). Transfer to a plate.
Cook the pasta according to the package directions. Reserve 1 cup of the cooking water; drain the pasta and return it to the pot.
In the same large skillet you cooked the onions in, add the butternut squash and 1½ cups water to the reserved skillet, cover partially, and cook (stirring occasionally), until it is very soft and most of the water has evaporated (about 8-10 minutes.
Toss the pasta, onion, butternut squash, pecorino, the remaining 2 tablespoons of butter, and ½ cup of the reserved cooking water together (adding more cooking water as needed to loosen the sauce).