Dark matter particles from the Galactic halo can be gravitationally trapped in the solar core or in external orbits. The enhanced density of dark matter particles either in the solar core or in external orbits can result in the annihilation of these particles producing gamma rays via long-lived intermediate states or directly outside the Sun, respectively. These processes would yield characteristic features in the energy spectrum of the subsequent gamma rays, i.e., a box-like or line-like shaped feature, respectively. We have performed a dedicated analysis using a 10-years sample of gamma-ray events from the Sun collected by the Fermi Large Area Telescope searching for spectral features in the energy spectrum as a signature of dark matter annihilation. In the scenario of gamma-ray production via long-lived mediators we have also evaluated the dark matter-nucleon spin-dependent and spin-independent scattering cross section constraints from the flux limits in a dark matter mass range from 3 GeV/c$^2$ up to about 1.8 TeV/c$^2$. In the mass range up to about 150 GeV/c$^2$ the limits are in the range $10^{-46} - 10^{-45}$ cm$^{2}$ for the spin-dependent scattering and in the range $10^{-48} - 10^{-47}$ cm$^{2}$ for the spin-independent case. The range of variation depends on the decay length of the mediator.