Can the lawyer testify before the trial?

Yes, but only with the consent of the other party.

The "Criminal Procedure Law" stipulates:

Article 41 With the consent of witnesses or other relevant units and individuals, defense lawyers may collect materials related to the case from them, or may Apply to the People's Procuratorate or People's Court to collect and obtain evidence, or apply to the People's Court to notify witnesses to appear in court to testify.

With the permission of the People's Procuratorate or the People's Court, and with the consent of the victim or his close relatives, or the witnesses provided by the victim, the defense lawyer may collect materials related to the case from them.