There are a lot of things you cannot do with your tax refund. You can find them here: http://robertspaynelaw.com/myutahbankruptcyblog/2014/03/27/what-do-you-do-with-your-tax-refund-before-you-file-bankruptcy-how-do-you-spend-it/
However, it is perfectly safe to pay your bankruptcy attorney with your tax refund monies. You can also pay your court filing fees (currently $335 for a chapter 7 and $310 for a chapter 13) from that same refund.
This is the reason that most bankruptcy attorneys have lean months from October through February (telling clients to wait for tax refund and not file just yet) and have wonderfully busy months between March and May (tax refunds pay for bankruptcy).
So yes, you can use your tax refund to pay for bankruptcy.