Yes, but shallots are preferable because they have a delicate flavor that isn't overpowering. Red onions are much more pungent. If you use red onions, thinly slice them to ensure they cook well.