Is it appropriate to email my former advisor and ask to be notified if/when they choose to fill that position?
It’s generally appropriate to ask about job opportunities and to express potential interest. However, I wouldn’t rely on the former adviser to remember to notify you of something several years later (for me it’s hard enough to remember what someone asked me to do last week), and asking for such an open-ended future commitment to notify you might come across as a bit insensitive. It might be better to phrase the request as a question about whether they anticipate that there would be openings soon, and if so, what would be a way that you could learn about them.
As a general rule, people will show more good will towards you and willingness to help you if you show yourself willing to do things yourself (like keep track of job postings at a place you’re insterested in) instead of asking them to do those things for you.
How should that email be phrased?
Since it sounds like it’s been some time since you’ve had contact with your undergraduate advisor, I suggest starting by saying hi, reminding them of who you are (there’s a good chance they’ll need their memories jogged, even if that may sound unlikely to you) and updating them about what you’ve been up to. They will probably be glad to hear you are now beginning a career in academia.
After that background, you can get to the point and simply say you’re writing to inquire about job opportunities that might open up in the immediate or near future. It’s okay to mention the professor retiring, but I should caution you that the way you’ve phrased your question suggests an implicit premise that departments always fill positions of professors who retire with new faculty who have similar expertise or are qualified to teach similar classes as the retiring professor. In my area (math) that is usually false. So keep that in mind when you mention how your own expertise overlaps that of the other professor.