Very easy, though I don’t normally add onions to pasta sauce. But when I do want to add onions to something – it’s most frequently beans – I sautee the onions in the same saucepan that I’m going to add the beans to. A regular heavy saucepan, not a non-stick.
You just chop up about half or a bit less of a peeled white onion (I always use white by force of habit) with a good sharp chef’s knife, then pour a couple of tablespoons of extra virgin olive oil into the saucepan. When the oil seems hot and is flowing readily, throw in a small piece of onion. If it sizzles, it’s ready to throw in the rest. Stir with a large spoon or spatula like in the picture below. (I normally just use a large spoon myself.) If you’re not sure when the onion is done, it’s definitely done at the first sign of starting to turn golden. Hint: white onion contains a lot of moisture, so use more than you think you’ll need – you’d be surprised at how much the volume reduces! And when I say “half”, I’m referring to a white onion, which are generally much bigger than yellow ones.
Garlic is much the same but it’s a pain to peel the cloves so minced garlic in a jar is often the better approach.