To make the pickling brine, combine the vinegar, sugar, salt, bay leaf, cinnamon stick, coriander seeds, juniper berries (if using), and red pepper flakes in a small nonreactive saucepan. Stir in 3/4 cup (180 ml) water. Bring the brine to a full boil over high heat, then reduce the heat to a gentle simmer. Add the shallots to the simmering brine and cook until they soften slightly but retain some crunch, 2 to 3 minutes.