If you're buying a bike and having it shipped to you then you don't have any control of how the sender packs it.
If its a new bike/frame, the manufacturer probably has experience in shipping their product. So it will either arrive fine or you have to make a warranty claim for "damaged in shipping"
Here's a rim I bought from China. It was well-enough packaged, but clearly got crushed in machinery somehow. There is no reasonable way this part could have been damaged like this by dropping or mishandling, it had to be great force.
Dog paw for scale.
Upshot was I got a refund and ordered a replacement. All I lost was time.
Now, if you're shipping something TO someone else, how you protect it is up to you.
For a bike, a hard-sided bike travel bag is good but they're expensive and unweildy. Manufacturers ship partially-assembled bikes in stout cardboard boxes, with layers of filler, and possibly paint protection as the final layer.
If you have the time/skills/patience, making a hard-sided shipping crate can provide the most physical protection.
Your other option is shipping insurance. Most carriers offer some level of financial payment if your bike or item is damaged/lost in shipping, possibly contingent on it being well-packaged.