You have to put it into a
Local Variables block.
%%% Local Variables:
%%% TeX-command-extra-options: "-shell-escape"
When I open the file Emacs warns me:
The local variables list in test.tex
contains values that may not be safe (*).
Do you want to apply it? You can type
y -- to apply the local variables list.
n -- to ignore the local variables list.
! -- to apply the local variables list, and permanently mark these
values (*) as safe (in the future, they will be set automatically.)
* TeX-command-extra-options : "-shell-escape"
When I answer
y and use the C-c C-c shortcut, I see in the log
Running `LaTeX' on `test' with ``lualatex --jobname=test -file-line-error -shell-escape -interaction=nonstopmode "\input" test.tex''
Your output might differ slightly because I have changed some of Emacs' and AucTeX's default settings.