Are general-use ball bearings okay?
Ideally, no.  Bearing balls are of such fine tolerance that a random substitution is likely to be bigger or smaller than your existing ones.
The best solution is to buy a set, then replace all the bearings on both sides of the axle.  That way they've come from the same batch and will be all the same size.   You can get bearing ball sets from your local bike shop or just buy 20 of the above.
A proper bike shop won't even reuse a new bearing that has dropped on the floor by accident, they'd just get another from the same batch.

Why is size such an issue?   Imagine if your single replacement was slightly larger.  The two balls either side of the new one would not take as much load, and may be free floating due to the bigger new ball taking extra load.
This leads to extra pressure on one ball and premature wear and failure, and at least two balls simply sliding around and not rolling.  This generates wear because of a lack of preload on those balls.
Upshot is Spalling where the big ball looses chunks, which adhere to the race, and then peel off leaving dents.  When this happens, your cones need replacing and/or the hub is dead.
If the new ball is too small, the same thing happens but the new ball simply slides and the two on either side take more load.
In short, a set of new bearings is cheap, just do it.  You can get loose balls or you can get balls in a cage which are more convenient, either is fine.

On the flip side, I have sometimes used a spare bearing ball to repair an old donor bike at a fixup.  A kids bike that might only do a hundred miles travel in its entire life would probably be fine for this fix, compared to a race bike doing a hundred miles a ride, or a long-distance commuter who does a hundred miles a week.
A bearing ball in a bicycle is not a high-load nor a high-speed application, so physically the bearing ball would function at the RPM and temperatures of a bicycle hub.  The size and tolerance is the main issue.
So it's up to you and the expected longevity you expect from that wheel.