You COULD say it this way, but it would be considered very odd wording.
A fluent speaker would be much more likely to say, "The ball is hollow" than "the ball has hollowness". And even more likely to say, "The ball is filled with air."
"Cavity" is usually used to describe a defect, a hole that isn't supposed to be there. Or at least that is unexpected. Like if something punched a large hole in the side of your house, you might say, "There's a giant cavity in the wall of my house." Or, if you found an empty space beneath a building that was created by some natural phenomenon, or by an unknown human agent, you might say, "There was a large cavity beneath the building." But if someone built a parking garage under the building, you wouldn't normally call that a "cavity". So I wouldn't use "cavity" to describe the empty space inside a ball.