Space under the stairs is easy to ignore because it's so well hidden. If the stairs aren't carpeted, carefully pry up a tread and use a flashlight to look underneath. If prying up a tread isn't an option, cut a small inspection hole in the drywall – it's much easier to patch a small drywall hole than replace a large piece.
If the space checks out, knock a larger inspection hole between two wall studs and take a closer look. Most stairs are well-supported at the top and bottom of the stringers. Make sure the stairs have this kind of stability before proceeding. Check with a structural engineer to determine if the wall is load-bearing – never remove studs from a load-bearing wall.
Locate the studs in the wall and determine the position for the closet door. Use a reciprocating saw or a drywall saw to cut the drywall – but not the studs – to accommodate the closet door.
Safety Alert: Reciprocating saws are powerful and can have a strong "kick." If you're not confident you can control the tool safely, get assistance or use a different tool.