Add the frozen pineapple, lime sherbet, tequila, triple sec, fresh lime juice, and agave (if using) to a high-powered blender. Blend on high, scraping down the sides as needed, until completely smooth and thick, 1 to 2 minutes.
Pour the mixture into a freezer-safe container with a lid and smooth the top. Freeze for at least 4 hours or overnight, until firm enough to scoop.
If you can, stir the mixture once after about 2 hours to break up ice crystals and keep the texture even.
Chill 4 margarita glasses in the freezer for 15 minutes. Run a lime wedge around each rim and dip the rim into coarse salt.
Spoon the frozen mixture into a piping bag fitted with a large star tip and pipe into the prepared glasses in a tall swirl.
Garnish each glass with a lime wedge and serve immediately with a spoon and a straw.