Senior government officials in multiple U.S.-allied countries were targeted earlier this year with hacking software that used Facebook Inc.'s WhatsApp to take over users' phones, according to people familiar with the messaging company's investigation.