You can freeze onions whole but it's not recommended.
When you freeze onions whole the whole onions when frozen whole can become soggy and mushy and not be as good.
If you do need to or want to freeze onions whole you should blanch the whole onions first in hot boiling water for around 7 minutes.
The blanching of the whole onions deactivates the enzymes in the onions so that they do not become soggy or mushy when frozen.
Blanch the whole onion or whole onions until the center of the onion is heated through.
It's best though to slice the onions up and then place them in Ziploc bags or freezer bags and then freeze them.
I always cut up the onions in slices and then blanch the sliced onions in the hot water and then after the onions cool down I place them in Ziploc bags and then freeze them.
Frozen onions an last up to a year but it's best to use the frozen onions within a few months to 6 months at most because the longer the onions remain frozen the less fresh they become.