It depends what you're using to access Mastodon.
If you're on the website, after the image is attached click the "edit" button on the image itself, you'll be able to add the caption there.
On apps, you can either click directly on the attached image or click on "caption" or "edit" or something similar.
In all these cases, writing the alt text happens before you publish. However, if you forget to add it you can always edit the post and add it in later.