Your problem is that your macro * reads only single following token (after ignoring spaces) because you say \def*#1{...}, i.e. the #1 is unseparated parameter. The first usage of * gets t to the #1 and the second usage (at the end of the phrase) gets \par to the #1 (if empty line follows) and the result is "paragraph ended before \par" because * isn't defined as \long. If there is \bye without empty line (this is exactly in your example) then \bye is scanned to #1 and the result is "Forbidden control sequence" because \bye is defined as \outer in plain TeX.
You can define "switching macro" \startit without parameter as follows:
\def\startit{\bgroup \let\startit=\egroup \it}
\catcode`=13
\def{\startit}
Test this is italic
\bye
The first usage of * starts the group, selects italic font and redefines \startit to \egroup. The second usage of * (at the end of the phrase) runs \startit in the meaning \egroup and closes the group (the italic font is not selected now). Moreover, the \startit gets its original meaning after \egroup, so next possible * opens italic text again.
Egreg showed an example how to combine * with italic meaning and ** with bold meaning. Moreower, ** in italic does nothing and * in bold selects bold italic. The same behavior can be achieved by following seven lines:
\font\bi=cmbxti10
\catcode`*=13
\def{\activeast}
\def\activeast{\futurelet\next\aastA}
\def\aastA{\ifx\next \expandafter \startbf \else \startit \fi}
\def\startit{\bgroup \def\startbf{}\let\startit=\egroup \it}
\def\startbf{\bgroup \let\it=\bi \def\startbf*{\egroup}\bf}
Hello, this is a test, to see whether it works.
\bye
Note that the code is much more compact than egreg's code at 34 lines.
$...$with\(...\), since keeping track of even-odd occurrences of $ is difficult (some editors change the font color with each occurrence). – John Kormylo Jun 21 '22 at 19:53markdownpackage ... – Fran Jun 22 '22 at 01:40\def*#1*{...}? – Gaussler Jun 22 '22 at 06:55