Can I use a macro in \halign's preamble?

Yes, you can: \span, when used in the alignment preamble, expands the next token.

\def\preamb{## & ## \cr}
\halign{\span\preamb
first line & second column \cr
}

\bye

As a rule, tokens before the first \cr are not expanded, unless they're preceded by \span. A different approach, if the preamble is stored in a single macro is

\halign\expandafter{\preamb
first line & second column \cr
}

but \span is more versatile.


You can use \span or \expandafter to expand macros in the preamble but in either case it forces a slightly unnatural call structure when you use the macro.

An alternative is to define an alternative command (myhalign here) that builds in the required preamble. You can avoid pre-scanning the alignment body by using a \let to gobble the { in the source allowing the preamble starting with an unmatched \bgroup to be inserted:

\def\myhalign{\afterassignment\xmyhalign\let\tmp=}
\def\xmyhalign{\halign\bgroup\hfil## & ##\hfil \cr}

\myhalign{
first line & second column \cr
1& 2 \cr
}

\bye

enter image description here