Here's a hacky way, probably this is the wrong way :).
Instead of passing a filename, you can pass a sequence of commands. So in particular, you could do something like
pdflatex "\def\ishandout{1} \input{foo.tex}" which defines the macro \ishandout (to be 1) and then reads foo.tex. And then, inside foo.tex, you can check whether \ishandout is defined:
\ifdefined\ishandout \documentclass[handout]{beamer} \else \documentclass{beamer} \fi