How closely can I follow a cited mathematical derivation in my PhD dissertation?

The appropriate wording for something like what you envision -- making clear that you are closely paraphrasing another publication -- would look like this:

Since the derivation of the result by [ABC, 1956] is not widely available in common textbooks, the remainder of this section closely follows the excellent outline provided previously in the MSc thesis by DEF, see [DEF, 1987]. In this thesis, the author shows that ...


The short answer is that you can indeed put properly cited, sourced, attributed background material in a background section. Because what is the background section for other than for you to present what people have done before you?

You obviously need to include enough of your own work in this document. However if a relevant derivation has been done before you cite it, possibly review it for the ease of the reader or completeness of your own expository structure and get on to the stuff you have done.