While beets are roasting, cook onions in oil in a 12-inch heavy skillet, covered, over moderately low heat, stirring occasionally, until soft, about 20 minutes. Add salt, sugar, and vinegar and cook, uncovered, stirring occasionally, until onions are very tender and caramelized to deep brown, about 20 minutes more. Add wine and boil, stirring occasionally, until liquid is reduced to about 2 tablespoons, 3 to 5 minutes. Transfer mixture to a food processor and pulse to a coarse purée. Return to skillet and season with salt and pepper if desired reheat onion marmalade, covered, over low heat. It is great at room temperature too.