I would never try to do this but I think theoretically it is possible but tricky since you have to charge at least fair market rent. Suppose you get a mortgage such that the interest plus depreciation of the home is equal to the rent. Then there is no income to pay taxes on but you can deduct the interest and property taxes.
I suppose you would have to sell within 2 years or stop renting for three years before selling to get the cap gains exclusion.
As an extra benefit, all repairs would be deductible as well as well as new appliances. Could write off the gardener as well. I wonder if you could rent it furnished so you can write of cable, telephone, sdg+e, and water!