I'm assuming that based on the owned 2 out of 5 year exclusion, that this sale was not taxable.
Legal fees are generally not deductible. There
are two significant exceptions
- Legal fees are deductible if
incurred to determine or collect any tax liability.
- Legal fees are deductible if the
suit is to secure taxable income.
Because of those
criteria, your legal fees would not be deductible.