Framing a door ON stairs, 3 steps to landing?
In every town that I have done building you would have to provide a landing area to put this door and the landing would need to be at minimum 36".  I do not know how that would work on an existing staircase so I would say the answer is simply no for most towns.

However your best bet is to call local inspector and ask them if they will allow anything or offer any alternatives.