In a small saucepan, whisk together the soy sauce, mirin, sake, and granulated sugar. Add the onion, ginger, and garlic if using.
Place the saucepan over high heat to bring to a boil.
Once boiling, reduce the heat to a simmer and cook, whisking occasionally, for 8 minutes. The sugar should be completely dissolved. If desired, continue to cook for a few more minutes to reduce the sauce and thicken slightly.
If you added the onion, ginger, and garlic, strain the mixture and discard the solids.
If not using right away, allow the teriyaki sauce to cool to room temperature, then store in an airtight container and refrigerate for up to 2 weeks.