Heat the oven to 425°F. Put the shallot or onion in a food processor and pulse until finely chopped. Add half of the mushrooms and pulse until very finely chopped (don't overprocess or the mushrooms will become a purée). Empty the workbowl, pulse the remaining mushrooms, and combine with the other mushrooms. (You can also do this by chopping everything finely with a knife.)
Heat the oil in a large skillet over medium high, add the mushroom mixture and salt, and sauté until all of the mushrooms' liquid has been released and evaporated completely, 8 to 10 minutes; the mixture should start to brown and stick around the edges. Season with the hot sauce. Remove from the heat, stir in the sun-dried tomatoes and Parmigiano; taste and adjust the seasonings.
Spread the filling on a plate and chill in the freezer while you prepare the pastry.
Lightly flour your work surface and roll the pastry sheet to a 10x15-inch rectangle. Prick the dough all over with a fork, and then cut it into four long strips, each 2-1/2 inches wide. Cut each of these strips into six equal pieces, to yield a total of twenty-four 2-1/2-inch squares.
Put a heaping teaspoon of the filling in the center of each square. Dab each corner with a little of the beaten egg and then bring all four corners up to the center and pinch well to fuse them together. You should have little square pouches, with some of the mushroom filling showing. If you have any egg left, you can brush it on the exteriors of the pockets.
Arrange the pockets on a parchment-lined or nonstick baking sheet and bake until they're puffed and deep golden on the sides and bottom and the pastry is no longer doughy 15 to 16 minutes. Let them cool on a rack for a few minutes and serve warm.