A search for excited electrons produced in $pp$ collisions at $\sqrt{s} = 13$ TeV via a contact interaction $q\bar{q} \to ee^*$ is presented. The search uses 36.1 fb$^{-1}$ of data collected in 2015 and 2016 by the ATLAS experiment at the Large Hadron Collider. Decays of the excited electron via a contact interaction into an electron and a pair of quarks ($eq\bar{q}$) are targeted in final states with two electrons and two hadronic jets, and decays via a gauge interaction into a neutrino and a $W$ boson ($\nu W$) are probed in final states with an electron, missing transverse momentum, and a large-radius jet consistent with a hadronically decaying $W$ boson. No significant excess is observed over the expected backgrounds. Upper limits are calculated for the $pp \to ee^* \to eeq\bar{q}$ and $pp \to ee^* \to e\nu W$ production cross sections as a function of the excited electron mass $m_{e^*}$ at 95% confidence level. The limits are translated into lower bounds on the compositeness scale parameter $\Lambda$ of the model as a function of $m_{e^*}$. For $m_{e^*} < 0.5$ TeV, the lower bound for $\Lambda$ is 11 TeV. In the special case of $m_{e^*} = \Lambda$, the values of $m_{e^*} < 4.8$ TeV are excluded. The presented limits on $\Lambda$ are more stringent than those obtained in previous searches.