There’s a couple things here.
During voir dire when the DA asks you if you are able to follow the law and send someone who helped a fugitive slave to jail if the case against them were proved, you would commit perjury if you said “yes” but intended to nullify.
Now, you face perjury charges. But, are there circumstances where it would be moral to commit perjury if by doing so you would prevent an even greater injustice? I think so. It seems to me to be moral to risk jail to help a fugitive slave to escape.
However, in almost all cases it is wrong to commit perjury, even aside from the legal risk you might be taking by commiting perjury. And of course, no officer of the court can advise someone to commit perjury. So if you tell your lawyer you’re gonna lie, I believe he’s obligated to try to convince you not to. And if he can’t, and he knows you’re going to commit perjury, he’s obligated to report your crime. Except he can’t, because the communication was priveleged. So he has to withdraw from your case. Except often the judge won’t let him withdraw. And you have the right to testify in your defense, if you chose to. So he’s got to ask the judge to allow you to testify in the narrative, which means he’s telling the judge that he knows you’re planning on committing perjury, but there’s nothing he can do about it, so please don’t disbar him. So the judge lets you take the stand and say whatever you like to the jury, and your lawyer stays out of it completely, and never references your lying testimony in any way later.
The prosecutor could later try to nail you for perjury, but I have no idea how likely that is to actually happen. I suppose the usual rule of thumb is that if you’re convicted the penalty for perjury is just another part of your sentence, and if you’re acquitted it would probably be pretty difficult to prove the perjury anyway…if they had a way to prove you perjured yourself they’d have brought it up in trial to impeach your testimony.
Anyway, long story short, no lawyer can ethically advise you to commit perjury, which is why you’ll never see a lawyer on these boards saying it would be OK to lie to get yourself on a jury to nullify an unjust law. And since any competant prosecutor will ask each jury member if they are capable of enforcing the law as written, you’d pretty much have to perjure yourself to be in a position to nullify a law.