The detail of the particle acceleration at trans-relativistic shocks is still under debate. We propose a way to probe the particle acceleration at trans-relativistic shocks with observations of gamma-ray burst (GRB) afterglows. In the afterglow phase, the shock wave launched in a GRB is gradually decelerated from the relativistic to non-relativistic regimes by sweeping up the ambient interstellar matter. If the electron power-law index depends on the shock Lorentz factor, it is reflected to the evolution of the afterglow spectrum. We theoretically study the time evolution of the electron power-law index imprinted in GRB afterglow spectra. We introduce a particle acceleration model by a trans-relativistic shock into the standard GRB afterglow model and apply the formulation to structured jet models that are consistent with GRB 170817A, which is the counterpart of the gravitational-wave signal GW170817 from a binary neutron star merger. As a result, we find that it is possible to observe the transition of the electron acceleration from the relativistic phase to the non-relativistic phase in the evolution of the afterglow spectrum, if GRBs similar to GRB 170817A take place in a dense environment at 200 Mpc. The detection number of short GRBs will increase in the era of the multi-messenger astronomy including gravitational waves. Thus, we expect that future GRBs can give a constraint on particle acceleration models as proposed in our study.