Yes, it is possible. You just have to define \mycmd the right way.
If modifier is a macro that takes an argument (like \mathrm), then you can simply do the following:
\makeatletter
\def\mycmd{%
S% <- put the actual \mycmd here.
\@ifnextchar_{_\expandafter\mathrm\@gobble}{}%
}
\makeatother
\@ifnextchar#1#2#3 is a macro from the LaTeX kernel, that simply checks whether the following character is equal to #1. If so, it executes #2, otherwise #3. In our case, we check if \mycmd is followed by an underscore (note that any whitespace is removed). If so, then _\expandafter\mathrm\@gobble is executed. Here \mathrm is the actual modifier. We want the underscore before the modifier, so we insert it at the beginning and remove the underscore the user typed with \@gobble (\@gobble simply removes its argument). The \expandafter makes sure that the underscore is removed before \mathrm looks for its argument (otherwise \mathrm would try to take \@gobble as its argument, leading to an error).
If \modifier is something that acts like \itshape or \color, one has to do something slightly more involved in order to get correct grouping:
\makeatletter
\def\myothercmd{%
T%
\@ifnextchar_{\myothercmd@}{}%
}
\def\myothercmd@_#1{%
_{{\color{red}#1}}%
}
\makeatother
Here the underscore is removed while \myothercmd@ searches for its argument, which is specified as _#1. Then the group after the underscore (i.e. #1) is reinserted together with an underscore and the the modifier in front of it. Of course this solution would also work with a modifier of the first case, e.g. defining \myothercmd@ as _{\mathrm{#1}}.
If you also want to allow superscripts, you can use
\makeatletter
\def\mycmd{%
T%
\@ifnextchar_{\mycmd@d}{\@ifnextchar^{\mycmd@u}{}}%
}
\def\mycmd@d_#1{%
_{{\color{red} #1}}%
\@ifnextchar^{\mycmd@u}{}%
}
\def\mycmd@u^#1{%
^{\mathrm{#1}}%
\@ifnextchar_{\mycmd@d}{}%
}
\makeatother
^and make similar definitions. – Leo Liu Jul 27 '11 at 05:53\color) need an extra group. – Caramdir Jul 27 '11 at 16:20