Yes, exactly like that.
Of course, it depends on whether the court can prove their recollection whether or not they can be punished, but the bottom line is that it’s still illegal and the court remains legally entitled to forcefully procure truthful thoughts and memories from a person.
I don’t support any suggestion that updating the law doesn’t matter because it is sometimes difficult to enforce, if that was your intention.
It’s a multi-edged sword. It also means someone could be forced to testify against a friend or loved one, and in a slightly removed example, my beliefs also apply to laws that allow individuals to be imprisoned for failing to provide a password to locked electronics, regardless of whether or not they actually remember it.
Maybe it would be a good middle ground to instead expand the privileges that allow members of a marriage to avoid testifying against one another, to include friends and family. The same reasoning applies, except that the state believes it can determine the strength and meaning of a relationship by its title and type alone.