If you're using PowerShell 7 the Set-Service cmdlet has a -Credential parameter that'll do that.
If you're using PowerShell 5 you have to use either WMI or the utility SC.EXE to do this.
This has examples of both and comments on some the problems with using WMI to accomplish this: powershell-script-to-change-service-account
There's also this, if you want to try it: changing-service-credentials-using-powershell