For a less formal but equally appealing presentation, you can spoon rather than pipe the filling into the shells.
Preheat oven to 400 degrees. Place the sweet potatoes on a parchment-lined baking sheet; bake until tender when pierced with a paring knife, about 45 minutes. Remove from oven; let cool slightly.
Line a rimmed baking sheet with foil; fit with a wire rack. Arrange bacon strips on rack, and sprinkle with brown sugar. Cook until well glazed and crisp, 12 to 15 minutes. Remove from oven; let cool slightly, and roughly chop. Set aside.
Melt 1 tablespoon butter in a small skillet over medium heat. Add shallots; saute until soft and fragrant, about 2 minutes. Add rosemary, and cook 1 minute more. Remove from heat, and set aside.
Slice each potato in half lengthwise. Carefully scoop out flesh, leaving about a 1/4-inch border all around potato halves; set halves aside on a baking sheet.
Place flesh in the bowl of an electric mixer fitted with the paddle attachment. Add remaining 2 tablespoons butter, reserved shallot mixture, egg, cream, and Gruyere. Mix well until combined. Season with salt and pepper.
Transfer mixture to a pastry bag fitted with a star tip; pipe into reserved halves. Bake until golden, about 20 minutes. Remove from oven; garnish with Gruyere, rosemary, and reserved bacon.