Yes, but it may end badly.
If you file a chapter 7, you can discharge your non-priority debts (priority debts are taxes/student loans/child support/criminal restitution). However, a creditor has a right to file an adversary proceeding against you for debts you incurred within 90 days of bankruptcy. If they win that suit (and they will), you have to pay that debt back to them after the bankruptcy.
So let’s say you take out a payday loan 2 weeks ago, realize you are in awful financial straights, and you file bankruptcy today. If they sue you in bankruptcy court, plan on paying that amount back.
If you file a chapter 13 case, you can propose to pay them back over a 5 year plan (60 months), and you can change the interest rate to 2%. This is much better than the 500%+ interest rate they’re currently charging you.
Payday loans are awful to begin with, and you’re generally taking them out because you’re desperate. People don’t take them out to defraud the creditor; they just feel that they have no other option to survive and cover the rent payment this month.
Just remember that it looks bad to take out a loan and then go bk a couple of weeks later, but so long as you’re not doing it intentionally to defraud the payday lender, it’s not the end of the world. And whatever you do, do NOT take out a payday loan to pay your bankruptcy attorney. That’s worse than you can imagine.