I'm not sure about one tool to do that, but if you want to stay in vector routing rather than a cost raster surface as per Steven Kay's answer, you can calculate the slope of your graph edges and use them as an attribute when routing. Generally you'd need to:
- Split all your edges into acceptably-small pieces* (actual length you choose depends primarily on your resolution of your elevation model).
- For the start and end of each edge, find the elevation.
- Use the start and end points' elevations to determine the approximate slope of the edge.
- Use the edge slope to influence speed (in your case, it might just be make edges with
slope > 30° impassable; but Tobler's hiking function is a useful approximation for influencing walking speed, and I've used something else when trying to approximate fuel consumption with respect to slope and speed assuming an average car).
This can be made more complex if you need, by actually considering three dimensional edges that have been draped over the DTM, rather than just splitting your edges and only considering relatively few intermediate points.
Once you have a topological network with slope attributes and/or modified travel time attributes and/or just impasses on roads with slope over your threshold, there are QGIS plugins for determining the shortest path, but I actually recommend pgRouting, as PostGIS will make the preparation work a lot easier (minus any learning curve).
* If you use very long edges, they may pass the crest of a hill, and so your calculation of slope will not be realistic.