An input mask is a valid UX pattern but I would recommend against using it.
Information on how to format an input is most needed when actually using the input. Just like a placeholder, masks lose their function at the point that users actually need them the most; while they are interacting with the input.
We suggest to ensure that formatting instructions are always visible Some relevant information can be found in the article by the NN Group on Placeholders.