Pack the onions into 2 (1-quart) jars and add enough water to come within 1/2-inch of the rim. Pour the water out into a measuring cup. Note the volume, pour off half of the water and replace it with vinegar. Add 2 tablespoons of sugar and 2 tablespoons of salt for every 3 cups of liquid.
Pour the vinegar mixture into a nonreactive saucepan, add the mustard seeds, red pepper flakes, coriander seeds, black peppercorns, garlic, and bay leaves, and bring to a boil over high heat. Allow the liquid to boil for 2 minutes, and then remove it from the heat.
Pour the hot liquid into the jars to cover the onions and screw on the lids. Refrigerate for up to 1 month.