Can you sell a house that has a second mortgage on it?

Absolutely, you can sell a house with a second mortgage on it. Keep in mind that you will have to provide clear title at time of closing and that the all mortgages (first and second) will need to be satisfied at closing which can be paid with the proceeds from the sale.