Wa alaykum salaam,
The area of legal practice is very challenging given the fact that there are varied challenges and scenarios.
What we currently advise people is to avoid any scenario where you are material and executing actual unlawful transactions or impermissible actions.
In scenarios where contracts are already drafted by your firm and you are not inserting any unlawful clauses from your own side, then this is less of a concern.
If majority of the services and responsibilities you are delivering as part of your job are lawful, then the small portion of your work for unlawful service, if you cannot avoid it, then as a last resort, you should purify the income gained in actual work doing the unlawful legal work, and also seek Allah’s forgiveness and assistance.
Allah knows best