Add the peppercorns, allspice, juniper berries, and bay leaf to a wide-mouth pint jar, or quart jar.
1/2 teaspoon black peppercorns, 1/4 teaspoon whole allspice, 1/4 teaspoon whole juniper berries, 1 crushed bay leaf
Peel onions and trim off ends, leaving as whole as possible. Set aside.
8 ounces pearl onions
Combine water, vinegar, sugar, and salt in a small saucepan and bring to a light boil, stirring to dissolve the sugar and salt.
1 cup water, 1 cup distilled white vinegar, 2 tablespoons granulated sugar, 1 tablespoon pickling salt
Add the onions and simmer 1 minute, then remove from the heat.
Scoop the onions into the jar. If you are using a pint jar, you will need to pack them in tightly. Pour in the brine. You may not use all of it; if using a pint jar use a chopstick to release any air bubbles, then add more brine as needed.
Let cool to room temperature, then place in the refrigerator. Let the flavors meld for at least 2 days (but better after a week or two) before enjoying.
Notes
Pickling salt is a fine grain salt. You can swap in fine sea salt.