Yes, you can hang cast iron pans on a wall rack, and it is one of the better ways to store them. Hanging keeps each pan separate, lets air reach every surface, and avoids the scratching that comes with stacking. The rack needs to be sturdy and the spot needs to be dry.
Why hanging suits cast iron
A pan on a rack is surrounded by air, so any moisture on the metal dries more easily. Each pan sits apart from the others, which means no stacking and no scratches on the cooking surface. It also keeps the pans visible, so you notice any spot of rust early.
Choose a dry spot
Hang the rack away from the stove, the sink, and the dishwasher, since steam and splashes can reach the pans. A wall in a normal room with steady humidity is better than a wall in a basement or next to a damp laundry area. Check the spot for signs of moisture before you mount anything.
Mount it safely
Find a stud or use anchors rated for the total weight. Cast iron is heavy, and a full rack adds up quickly. Check the weight rating of the rack and of the hardware, and do not load it beyond that. Use a level so the pans hang straight and do not slide.
Hang the pans
Hang each pan by its handle hole or on a hook made for it. Place the heaviest pans toward the wall side, and keep the rack from holding more pans than it is rated for. Leave space between pans so air moves between them.
Keep them dry
Dry each pan fully before you hang it. Look at the pans now and then, especially in humid months, and wipe any dust or spots. A thin oil coat helps when the room is humid.
Keep grease away
Splatter from the stove can coat the pans on a rack near the cooking area. Greasy pans collect dust and can hold moisture, so keep the rack at a distance from the stove if you can.