Stern-Gerlach apparatus measures the magnetic moment. How to measure spin? Since the Stern-Gerlach apparatus employs a magnetic field, it actually measures the magnetic moment $\mu$. If you assume a certain proportionality constant between $\mu$ and spin, then you can also indirectly measure the spin.
Is there a way to directly measure the spin of the electron or a neutron without having to deal with their magnetic moment? In other words, how to operationally define the spin of an elementary particle without any recourse to their magnetic moments?
 A: The most direct measurement of "intrinsic" angular momentum as angular momentum that I know of is Beth's experiment, in which a beam of circularly polarized light is reflected from a plate.  We can treat this beam as a stream of photons with a certain amount of angular momentum each.  The photons change their angular momentum state when they are reflected, which implies that there must be a torque on the system.  By suspending the apparatus from a torsion balance, Beth could then measure this torque;  it was consistent with an angular momentum per photon of $\hbar$.
This is a measurement of the angular momentum of photons, of course, not of electrons.  But if we accept that angular momentum is also conserved in atomic emission processes (e.g., the 21-cm line), then the fact that photons have an angular momentum of $\hbar$ implies that the possible angular momentum states of an electron must be spaced by increments of $\hbar$.   And if we then accept that there are only two possible electron spin states, then the only possible values of an electron's spin are $\pm \hbar/2$.
There also have been experiments such as the Einstein-de Haas effect which manipulate the angular momenta of the electrons more directly, via changing the magnetization of a ferromagnetic sample.  However, in such experiments it is generally not possible to guarantee that all of the electrons are spin-polarized, and so we cannot extrapolate the angular momentum of one electron from the change in the angular momentum of the sample.  Instead, it is more common to directly measure the ratio $\Delta J/\Delta M$, which works out to be a weighted average of the electron's spin and orbital angular momenta.
A: In this arxiv paper a patented method of measuring the spin of a free electron using he Stern Gerlach method is published

Stern-Gerlach experiment by free electron is very important experiment because it answered some questions that remain unanswered for almost a century. Bohr and Pauli considered its objective observation as impossible while some other scientists considered such observation as possible. The experiment on free electrons has not been conducted so far because the high magnetic field gradient predicted there was thought as impossible to generate. This paper proves that it is not only possible but also observable using a high vacuum lamp which is deionized well. To obtain a high magnetic field gradient, it is not necessary to have a very strong magnetic field and it is possible to observe the phenomenon using a very sharp pointed magnet and adjusting the voltage in a certain distance from free electron beams.

see this figure

you ask:

In other words, how to operationally define the spin of an elementary particle without any recourse to their magnetic moments?

The use of the magnetic moment in the experiment above shows that there are two states, which within the group theory for particles leads to spin +/-1/2 for the electrons in the beam. If there were three states on would have proof of -1,0,+1.
Once one has particles with known spin, the new particles decaying into known ones can be shown to be of a specific spin, without recourse to magnetic moment, using the expected distributions predicted , as was done recently with identifying the spin of the Higgs boson.
A: There are many different methods that can be used without considering magnetic moments or assuming a g factor.
You can count states. For example, if the Stern-Gerlach experiment shows that silver atoms have two states, then they must have spin 1/2.
Similarly, you can note that helium is a noble gas, and that an alpha particle is a doubly-magic nucleus. This stability of particle number 2 can only be explained if the state counting is based on spin 1/2 for electrons, neutrons, and protons.
In nuclear physics, when we want to know the spin of an excited nuclear state, a common technique is to observe the angular distribution of photons emitted from that state. This angular distribution depends on both the initial and the final spin of the nucleus.
For bosonic fields, there are classical observables associated with the field, and therefore we have classical field theories. This one way of knowing that the photon should have spin 1, and is currently our only way of predicting that the graviton should have spin 2.
The relativistic spin-orbit coupling depends on the spin. (But in nuclei there is also a bigger effect with the opposite sign due to the properties of the strong nuclear force.)
A: Here is my understanding of it. I will take the help of two widely read books: Griffiths QM - 2nd ed. (Ref. 1) and Sakurai's Modern Quantum Mechanics - revised ed. (Ref. 2)
PART 1: WHY ARE ELECTRONS CONSIDERED TO HAVE A SPIN ANGULAR MOMENTUM?
Since electrons respond to a magnetic field, they are said to have a magnetic moment, and a Hamiltonian $H = - \vec{\mu} \cdot \vec{B}$ is lifted from classical physics, with $\mu$ being the magnetic moment. Under this $H$, the e- have been found to rotate (or precess; i.e. Larmor precession). It is simply a precession of the magnetic moment which is detectable when placed between the Stern-Gerlach magnets. This precession has been worked out in Example 4.3 of Ref. 1
Sec. 3.2 of Ref. 2. Only if we assume $\vec{\mu} = \gamma \vec{S}$ ($\gamma$ = gyromagnetic ratio) the evolution operator $\exp(- i H t/ \hbar )$ becomes $\exp( i \vec{S} \cdot \vec{B} ~\gamma  t/ \hbar )$ which is a rotation operator (recall that spin is the generator of rotations). Hence, ascribing  the magnetic moment to some kind of angular momentum seems reasonable.
PART 2: HOW TO DEFINE/MEASURE THE MAGNITUDE OF SPIN?
We will work things out for the case of $s=1/2$, i.e. an e-. Higher $s$ cases can be dealt with similarly. Sec. 3.5 of Ref. 2 works out the eigenvalues of spin operators with
$$ [S_i,S_j] = \alpha ~\epsilon_{ijk} S_k,  $$
as the starting point (the book takes $\alpha= i \hbar$ from the get-go but we will arrive at this conclusion later). These relations give the eigenvalues of $S^2$ and $S_z$ to be $-s(s+1) \alpha^2 $ and $-i m \alpha$ where $s$ is determined by the number $N$ into which a spin multiplet splits when the e-  beam is sent through the Stern-Gerlach apparatus such that $N = 2 s+1$. All this comes from the angular momentum algebra presented in Sec. 3.5 of Ref. 2.
Further from Example 4.3 of Ref. 1, we can see that
$$
H = - \vec{\mu} \cdot \vec{B} ,  \\
\vec{\mu}  =  \gamma \vec{S} , \\
\omega = \gamma B   ,
$$
where $\omega$ stands for the Larmor precession frequency. Upon measuring $\omega$ and $B$, $\gamma$ can be computed. Since the energy change associated with the change of one angular momentum/spin state to another can be measured, $\Delta H = - \Delta \vec{\mu} \cdot \vec{B} = - \gamma \Delta \vec{S} \cdot \vec{B}   = - \gamma i (\Delta m) \alpha B$ lets us determine $\alpha$. We assume here that $\vec{B}$ points in the z-direction. My guess is that $\alpha$ comes out to be $i \hbar$ (which all textbooks assume from the get-go and write $ [S_i,S_j] = i \hbar~\epsilon_{ijk} S_k,  $ instead of $ [S_i,S_j] = \alpha ~\epsilon_{ijk} S_k,  $).
Hence, measured values (eigenvalues) of $S^2$ and $S_z$ become $s(s+1) \hbar^2$ and $m \hbar$, respectively. Note that to measure quantum spin, we did not measure some position and momentum vector and took its cross product. Associating the spin with a magnetic moment and studying its Larmor frequency as well as borrowing concepts from classical physics is crucial to operational define spin in quantum mechanics.
For more insight, check these out too:
Looking Glass Universe video 1
Looking Glass Universe video 2
