Here is something similar you will find in the below thread where they have created a script that displays all the sites in IIS and you pick the one to update.
The script changes out the cert in the bindings and updates the thumbnails where needed in the config.
The script is too long so I am not adding this to this answer, You can download the file using the below link.
https://community.sitecore.com/community?id=community_question&sys_id=66ab9a391be2c19038a46421b24bcbe4
Change the extension from .txt
to .ps1
Hope this will solve your issue.