Your eligibility for mortgage modification depends on the willingness of your lender to modify the mortgage, as well as on what chapter of bankruptcy you file. Chapter 7, or total liquidation bankruptcy, allows you to keep only a limited amount of equity in your house. Many people who go through chapter 7 do not, in fact, end up keeping their homes at all- although this isn't necessarily always the case. However, chapter 7 doesn't involve a modification of debt, so you probably will not wish to choose chapter 7 if one of your aims is to get your mortgage loan modified as part of the bankruptcy.
On the other hand, mortgage modification Chapter 13 bankruptcy is more common. Typically, this is done through something called a "cram down." A cram down occurs where the
mortgage lender agrees to lower the balance owed to become more in line with the fair market value of what the home is actually worth. A lender will have to agree to a cram down. You may also be able to agree to negotiate or modify mortgage payments throughout the chapter 13 process. You also don't need to worry about losing any assets- including your home- in a chapter 13, since the purpose of this chapter of bankruptcy is to allow you to repay your debts over a 3-5 year period.
To determine what chapter of bankruptcy is right for you, and whether or not you might be eligible for a cram down or a mortgage modification as a part of your bankruptcy filing, you should strongly consider speaking with an experienced bankruptcy attorney for help.