The short answer is yes, you can file bankruptcy. But then you have to ask if that will discharge (get rid of) those gambling debts. The answer to that depends of in what state you gambled and ran up those debts.
• California – California gambling debts are treated like any other debts. Of course if it looks like you intended to file bankruptcy when you ran up the gambling debt, you may have a problem. Or they may be considered "luxury" goods for services if incurred within 70 days before filing bankruptcy. But that's really no different than for other types of debt.
• Nevada – In Nevada, gambling is a huge industry and casinos have political power. In Nevada, casino markers are treated like checks, and the failure to pay a marker is a "bad check" felony. If you are in this situation, time is of the essence. File bankruptcy before the casino deposits your check or marker, and you avoid criminal prosecution. File afterward, and your matter will be referred to the District Attorney. Assuming you don't live in Nevada but only gambled there, make sure your local bankruptcy attorney contacts a Nevada bankruptcy attorney so you get the best result possible and don't get a criminal conviction.
• Other states – In most states, the result will be like California. But your bankruptcy attorney will have to check to make sure that state doesn't have laws similar to Nevada.
That's definitely a short course only, but it covers the basics and in particular warns you about Nevada gambling debts where the odds are very much stacked in favor of the house.