An alternative approach using \@ifnextchar:
\documentclass{article}
\begin{document}
\makeatletter
\newcommand\@s{S(\theta)}
\newcommand\s@opt[1]{S^{#1}(\theta)}
\newcommand\s{\@ifnextchar\bgroup\s@opt\@s}
\makeatother
\[ \s\s{2} \]
\end{document}
Whats going on here is that when you do \s, then \@ifnextchar checks the next character.
If it is an opening bracket (or any \bgroup), then it executes \s@opt, if not it executes \@s. \s@opt expects one argument, but \@sdoes not.
That is: if the next character is a \bgroup (opening brace*) then LaTeX replaces \s with the \s@opt, else with the \@s.
Below this point at your own risk.
Down the rabbit hole we go:
You can do even more fancy stuff here, like make \s^{2} -> S^{2}(\theta) like so**:
\documentclass{article}
\begin{document}
\makeatletter
\newcommand\@s{S(\theta)}
\def\s@pow^#1{S^{#1}(\theta)}
\newcommand\s{\@ifnextchar^\s@pow\@s}
\makeatother
\[ \s \] %<- prints S(\theta)
\[ \s^{2} \] %<- prints S^2(\theta)
\end{document}
OR you could do an optional squaring, like \s{\theta}^{2} -> S^{2}(\theta) whilst \s{\theta} -> S(\theta):
\documentclass{article}
\begin{document}
\makeatletter
\def\s#1{\def\res@a{#1}\@ifnextchar^\s@pow\@s}
\def\@s{S(\res@a)}
\def\s@pow^#1{S^{#1}(\res@a)}
\makeatother
\[ \s{\theta} \] %<- S(\theta)
\[ \s{\theta}^{2} \]%<- S^{2}(\theta)
\end{document}
*:unless otherwise defined, which it's usually not.
**: This is probably not recommended because of some reasons. I do not know these reasons, but I feel like I'm doing something hacky?
\newcommand{\s}[1][]{...}– Phelype Oleinik Apr 30 '18 at 14:13\s[2]with square brackets. Then, the optional argument works as desired (i.e., producingS^2(\Theta}). – Steven B. Segletes Apr 30 '18 at 14:50