Some governments in need of money have been turning to an obscure financial product typically used by hedge funds, exposing bond investors to new risks.