Will it be difficult to get a PhD position if the economy enters into a recession?
An article in the Chronicle of Higher Education suggests that the overall enrollment picture for undergraduate education was only mildly effected by the 2008 recession. 

However, many of those students chose community colleges rather than traditional four year colleges. This might suggest a downward pressure on doctoral admissions as there might be a lesser need for TAs in such a situation. This might affect admissions in such fields as mathematics that depend heavily on TAs for undergraduate teaching and teaching support. 

Of course there is more to the picture. Research needs go on and it might matter more whether governments (the NSF, say) can maintain funding for doctoral students. If a recession is mild or short lived, expect small effects, though more negative than positive. But it also depends on the attitude of those in congress who provide the funding levels for such things. 

Moreover, if there are fewer positions open for doctoral education, and more applicants, the competition might increase and it might be harder for any given individual to find a slot. Unfunded slots are probably easier to come by, of course, since the student helps fund the education to a greater degree than one who is grant or university funded. 

But in this case there are effects beyond the economic ones. In a pandemic it is hard to predict what might come. Some pandemics (bubonic plague and the arrival of Europeans in the Americas) have been devastating. 

Finally, the outlook for graduates of doctoral programs might be clouded in such a complex situation. But, the economy is cyclic in any case and some of us graduated into terrible academic economy conditions and others not. It is hard to predict what will happen over a five to seven year period. 

Your own field is probably a good one to be in, since many trends seem to imply an increase in the need for non-fossil energy production and storage. And in general, the effects can vary tremendously by field. 

But competent government helps. 

But all of the above is crystal ball gazing with not a lot of hard evidence. A deeper plunge into the question will likely reveal some research on the topic. But with the caveat that things that seem the same might be quite different. There are a lot of variables.