In a small saucepan, combine the cranberries, sugar, and water. Bring to a boil over medium heat, then reduce to low and simmer for about 10 minutes until the cranberries burst and the mixture thickens slightly. Remove from heat and let it cool.
Once the cranberry syrup has cooled, strain it through a fine-mesh sieve into a bowl or jar to remove the solids. This should yield about 1 cup of cranberry syrup.
In a cocktail shaker, combine the freshly made cranberry syrup, tequila, lime juice, and triple sec. Fill the shaker with ice, cover it, and shake well for about 15 seconds until chilled.
Prepare the glasses by rubbing a lime wedge around the rim and then dipping it into coarse salt or sugar to coat the rim.
Strain the margarita mixture into the prepared glasses filled with ice.
Garnish each drink with a lime wedge and a few cranberries if desired.