The conservation of matter is an amazing thing.
If you wish to make an apple pie from scratch, you must first invent the universe - Carl Sagan
Yes. Though to be more precise, in the process of using fertilizers, even the atoms are conserved. Though you will have to re-build the molecules.
On the practical side: Using coal as a raw material, you should be able to make fertilizers with only somewhat more energy than from oil.
As long as we have enough energy, we can make fertilizers. Of course, petrochemicals are a nice raw material, but not necessary.
And we are not running out of energy, anytime soon. (Though we may run out of oil.)