Você precisa identificar os dois padrões A e B em uma única passagem e, depois, alterá-los posteriormente. A seguir, os dois padrões são mesclados em um (A|B) e marcados com o prefixo string XXX . Em seguida, ele procura por XXX e o padrão A para a substituição real. Da mesma forma, para B .
Isso não manipula seu caso 'a*b'c* semi-aninhado.
awk '{ str = $0
str = gensub(/('[^']*'|\*[^\*]*\*)/, "XXX\1", "g", str);
str = gensub(/XXX'([^']*)'/, "\\texttt{\1}", "g", str);
str = gensub(/XXX\*([^\*]*)\*/, "\\textbf{\1}", "g", str);
print str
}' <<\!
'abc' *abc*
'.*' text '^.*$'
'*abc*'
'...*...*...'
'...*...'...*
!
Saída
\texttt{abc} \textbf{abc}
\texttt{.*} text \texttt{^.*$}
\texttt{*abc*}
\texttt{...*...*...}
\texttt{...*...}...*