Make sure you use an uncompromised device to change your Google password. I'd suggest removing your Google account from the phone before resetting, to avoid problems with factory reset protection (a password change and reset close in time is a pattern often seen when a phone is stolen, so could result in you being locked out for a couple of days). Don't enter your new password on the phone until you know it's clean, and enable two factor authentication on your account.
The tricky bit is restoring data and apps after a reset. If the problem is an infected app you don't want to just restore it. So some care with what you restore after a backup and reset is needed.