In a large skillet over medium heat, melt the butter. Add the sliced onions, salt, and sugar. Cook, stirring occasionally, until onions are soft and deeply golden brown, about 35–40 minutes.
If using wine, add it to the pan and cook until almost completely evaporated, about 2 minutes. Remove from heat and let cool slightly.
In a mixing bowl, combine the cooled caramelized onions, sour cream, mayonnaise, thyme, black pepper, and garlic powder. Stir until smooth and well combined.
Transfer the dip to a serving bowl, cover, and refrigerate for at least 1 hour before serving to allow flavors to meld.
Notes
For best flavor, make this dip a day ahead and refrigerate.