It’s perfectly fine to store a bike vertically. There are tons of vertical bike racks and storage options to choose from and it’s one of the more space-friendly storage positions. One thing to be mindful of: a bike with hydraulic brakes cannot be stored upside down. When upside down, air will fill the calipers of hydraulic brakes, making them spongy and requiring a brake bleed (which you may be able to handle on your own, but if you’re unfamiliar with the process you may need to take it in for servicing). It doesn’t matter so much if the bike has rim brakes, but bicycles with hydraulic brakes should be stored right-side up with the handlebars on top.