How to cook a fish to make its bone as soft as those in sardines?
Sardines are canned, which means the high heat of a pressure canner.  That is what softens the bones.  If you are wanting softer bones for other kinds of fish, you can either cook them using a pressure cooker or can them.  However, this will only work for smaller fish that have smaller bones.

If your main concern is that you will swallow a bone and choke, then buy your fish as fillets only.  Most fish fillets have no bones at all. The pin bones that are in salmon fillets can be removed with needle nose pliers, and are so small that you couldn't choke on them if you tried.