Yes cooked onions can be frozen.
When freezing cooked onions place them in a heavy duty freezer safe bag or in an airtight freezer safe container.
You can also refrigerate the cooked onions for eating later on.
But freezing the cooked onions extends the shelf life of the cooked onions.
Then just thaw them out when you're ready to eat the cooked onions again.
You can also extend the shelf life of raw onions but either freezing them whole or cutting them up and freezing the cut up onions.
Cooked onions should last for up to 6 months or even a year when frozen and raw onions should last the same amount of time in the freezer.