Add butter to a sauté pan and set over medium heat. Once melted, add the onions and cook until very soft. This will take about 20 minutes. Add the balsamic vinegar and cook 5 minutes more. Set aside.
Preheat oven to 400°F.
Unfold/unroll puff pastry and lay on a parchment-lined baking sheet. Prick all over with a fork, leaving a half-inch border. Spread the mascarpone cheese over the same area. 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 20 minutes, until the edges are puffed and brown.