Follow that instinct. It is the right one.
People who end up incarcerated, even for a short stretch, often find themselves suddenly very alone. Friends pull back, professional relationships go quiet, and the public embarrassment of the situation can make someone feel like the people who admired them must now think less of them. Hearing from someone who genuinely looks up to them during that period carries more weight than you might expect.
Your letter does not need to be complicated or lengthy. It does not need to address the circumstances that put them there or offer any judgment either way. A sincere note that says you are thinking of them, that their influence on your life has mattered, and that you wanted them to know someone is in their corner is exactly the kind of thing that helps a person get through a hard stretch with their sense of self intact.
The fact that you are asking whether it is appropriate rather than just assuming it is welcome shows a level of thoughtfulness that will come through in whatever you write. That sincerity is precisely why you should send it.
InmateAid makes it straightforward to send a letter without your home address appearing on the envelope, which is worth considering if you prefer to keep your personal information private.
A few months goes by faster with something real to hold onto. Be that for someone who clearly meant something to you.