For an academic writing, is it correct to say: "This variable needs not to be known."? I would be grateful if you could tell me possible differences in British and American usage.
No. We generally wouldn't use this construction, but what it sounds like you mean is
"This variable needs to not be known."
Ie that we specifically do not want anyone to know what the variable is.
If that is what you intended to say, then you could say that, ie just say "This variable needs to not be known.", although strictly speaking it is us who have the needs, not the variable (a variable doesn't have needs or desires), so we might instead say "We need the variable to remain unknown".
If what you intended to say is that it doesn't matter whether you know it or not, you would say
"This variable does not need to be known.", or, again, putting the needs onto us rather than the variable, "We don't need to know the variable".
It may be grammatically correct, but it is probably not what is intended. Presumably, what is meant is, The value of this variable does not need to be known (it is difficult—but not impossible—to know a variable), although there are other less awkward ways of saying this.
When I first read the sentence, I thought it meant something like it is important that we not know what this variable is, similar to a much-needed gap in the literature (google the latter).
In this case, there is likely no difference between BrE and NAE.