I know they can and do change the vaccines for this reason. I'm not sure if they are able to do it beforehand though because it would require guesswork. They've no doubt got machine learning involved though. The technical side of creating vaccines is very impressive. I haven't checked, but maybe they do something similar with the flu.
A problem just popped into my mind as of typing, but what happens when there's micro variants that are affecting small clusters of people. For example, I could have COVID and spawn a variant that's passed to my partner, he friends etc. With many of these micro variants is it even possible for a single vaccine to protect against this?