See what AI says
Yes, it is grammatically correct to say "to not do something," although "not to
do something" is more common and often preferred, especially in formal writing.
Both options are acceptable in modern English, even though the former involves a
"split infinitive".