It is legal: anyone may make an observation or suggestion to someone in a trial (so long as the judge doesn't bar or prevent it; the judge has the authority to control his/her courtroom and also the conduct of the trial). It is also not unethical, since this person, if he was the defendant's friend, had no legal or ethical obligation to not help his friend; only if the attorney had represented you and was using information from nis representation or compromising his representation of you would this be unethical. But absent some tie or connection to you, he could help his friend.