In a small saucepan, cook down the onion with a few splashes of balsamic until soft and caramelized. (This will take a while.)
Preheat oven to 400°F. Unfold puff pastry and roll out, if desired - but you can just use it as is. Prick all over with a fork. Spread the mascarpone cheese on, leaving about a half inch border all around. Scatter the onions across the tart, and top with slices of fig. Using a pastry brush, apply the beaten egg to the border.
Cook for about 30 minutes, until the edges are puffed and brown.