The board of directors of an irrigation district may authorize an attorney of its choosing to defend an officer, employee, or agent of the district, present or former, who requests representation as a result of an action, claim, or proceeding instituted against him or her. The costs of defense, including attorney's fees and any obligation for payment arising from the action, may be paid from district funds. Costs of defense, and judgment or settlement not in the person's favor, shall not be paid by the district if the court finds the person was not acting in good faith or within the scope of the person's employment or duties for the district.