I want to make specific entities have the Invulnerable tag until the player gets an advancement

So I'm making a modpack and I want to make bosses invulnerable until the player gets a specific advancement. Once the player gets that advancement a specific boss will have the invulnerable tag removed and any new ones that spawn will no longer spawn with that tag. how would I go about doing this? for example. all of the mutant creatures bosses will have the invulnerable tag but once the player gets the advancement that allows them to kill the mutant zombie it will then be killable but the other bosses wont be killable until the player gets the advancement to allow them to kill those bosses

Continue to help post