Sterilize 2 quart-sized (32-ounce) jars by washing the jars and the lids and rinsing with very hot water. Boil the lids in a small pot of water for 5 minutes. Put the jars on a rack set inside a deep pot and fill the pot with water. Boil the jars for at least 15 minutes, then turn the heat off and let sit in the water until ready to fill the jars.
In a medium pot, combine the vinegar, water, sugar, and salt. Bring to a boil over high heat. Remove from heat when boiling.
Remove the jars from the water and let dry for a few minutes on a towel. Divide the garlic, dill, and red pepper flakes (if using) between the jars. Add the green beans to the jars, standing them on their ends. Add the hot vinegar mixture to the jars, leaving ¼- to ½-inch of space at the top. When cooled to room temperature, screw on lids and refrigerate for at least 1 week to pickle. Pickled green beans will last about 1 month refrigerated.