There isn’t a diagnostic that could be ran on an iPhone for a virus or being hacked. If you believe you’ve been hacked or you have a virus, I would factory reset the phone and set up as new without using a back up and see if the issue is still going on. Also make sure you change your password before your factory reset from your settings prior to any changes to your phone. When reset your password make sure you sign out all your devices. You are given that option.