How far can an attorney go in attacking and trying to discredit an expert witness?

The U.S. Court of Appeals, 7th Cir dealt with an attorney who in, in a used car dispute:

…went after the plaintiff’s expert witness, Donald Szczesniak. Brodsky accused Szczesniak of fabricating expert reports in this and other cases, and he submitted an affidavit from one of Szczesniak’s former clients, Diane Weinberger, to support his accusations. Two weeks later, Brodsky filed a motion asking the district court to hold Szczesniak in criminal contempt and to refer him for prosecution to the United States Attorney. In that motion Brodsky accused Szczesniak of damaging a fence at Weinberger’s home in order to intimidate her into not testifying against him and of sending Brodsky an anonymous fax to discourage Brodsky’s own investigation into Szczesniak’s background. The district court summarily denied the motion, explaining that “[t]he judicial branch does not direct the executive branch to bring criminal prosecutions.” Undeterred, Brodsky filed a motion for sanctions against both the plaintiff and Szczesniak. The plaintiff denied the allegations regarding the damaged fence and the anonymous fax and submitted affidavits from Szczesniak, his wife, his mother, and his son that showed Szczesniak had been elsewhere at the time of the incidents. Brodsky responded by alleging that Szczesniak had lied in his affidavit and questioning whether Szczesniak’s son even existed. Szczesniak sought and received permission from the court identify any way in which additional procedures might have made a difference in his case, we decline to address this argument. to respond directly to Brodsky’s accusations, and Brodsky continued to accuse him of falsifying reports and engaging in a “routine practice of intimidation and retaliation.”
Brodsky’s misconduct ultimately eclipsed the lawsuit. The parties settled their dispute, but the court retained jurisdiction to determine whether Brodsky should be sanctioned. During the court’s three-hour evidentiary hearing, Szczesniak and Lubin both testified and were subject to cross-examination regarding Brodsky’s accusations against them. Brodsky, however, declined to testify or offer any new evidence in his defense (apart from a copy of Weinberger’s report to the police about the damage to her fence). In lieu of testifying, Brodsky asked for and received permission to make a statement apologizing for his conduct.
The court sanctioned the attorney for his actions:

The district court decided to sanction Brodsky under its inherent authority. The court noted Brodsky’s “unprofessional, contemptuous, and antagonistic behavior directed at opposing counsel” throughout the litigation but focused primarily on his allegations and attacks levied against Szczesniak. It described these actions as “wildly inappropriate” and concluded that they were undertaken “in bad faith, in an attempt to improperly impugn Szczesniak’s reputation before the Court, to have the Court potentially disqualify him as an expert, or at least [to] intimidate Szczesniak to the extent he would not testify.” The court also found Brodsky’s attempts at mitigation to be “wholly inadequate for his egregious conduct.” Based on these findings, the court directed Brodsky to (1) pay a $50,000 fine to the clerk of the district court, (2) attend an ethics course approved by the Illinois Attorney Registration and Disciplinary Commission, and (3) attend an anger management class. The court also referred Brodsky to the district court’s executive committee to consider barring or suspending him from practicing law in that district.
See:

DONALDSON TWYMAN, Plaintiff-Appellee,
v.
S&M AUTO BROKERS, INC., Defendant.
APPEAL OF: JOEL ALAN BRODSKY.
No. 18-1811
United States Court of Appeals, Seventh Circuit.
January 18, 2019.