MySQL server parameters default empty string to null
There is no way to do that by changing a server parameter. NULL is different from an empty string so there is no reason to have that.

You could change your application to send NULL to your SQL statement or add a condition to your query.

INSERT INTO table (column1) values (IF(LENGTH('$variable')=0,NULL,'$variable'));