Q:

Is it grammatically correct to write: "It needs not to be known"? 

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. 

A:

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".