In a small saucepan, combine the blackberries, sugar, and water.
Bring to a simmer over medium heat and cook for 6–8 minutes, stirring occasionally, until the berries have released their juices and the mixture thickens slightly.
Strain through a fine mesh sieve into a jar, pressing to extract all the liquid. Discard the solids.
Stir in the lime juice, if using, and let the syrup cool completely before using.
Make the Margarita:
Optional: Rim glasses with a lime wedge and dip into salt or sugar. Set aside.
In a cocktail shaker, add the smashed or puréed blackberries.
Pour in tequila, triple sec, lime juice, and the cooled blackberry syrup. Add a generous amount of ice.
Shake vigorously for 15–20 seconds until well chilled.
Double strain into prepared glasses filled with fresh ice, if desired, to remove seeds and pulp.
Garnish with fresh blackberries and a lime wedge.
Notes
Refrigerator: Store the blackberry syrup in a jar or airtight container in the refrigerator for up to 2 weeks.
Freezer: Freeze the syrup in an airtight container or in an ice cube tray. The syrup cubes are perfect for making frozen blackberry margaritas in your blender!