Excitons -- bound electron-hole pairs -- play a central role in light-matter interaction phenomena, and are crucial for wide-ranging applications from light harvesting and generation to quantum information processing. A long-standing challenge in solid-state optics has been to achieve precise and scalable control over the quantum mechanical state of excitons in semiconductor heterostructures. Here, we demonstrate a technique for creating tailored and tunable potential landscapes for optically active excitons in 2D semiconductors that enables in-situ wavefunction shaping at the nanoscopic lengthscale. Using nanostructured gate electrodes, we create localized electrostatic traps for excitons in diverse geometries such as quantum dots and rings, and arrays thereof. We show independent spectral tuning of multiple spatially separated quantum dots, which allows us to bring them to degeneracy despite material disorder. Owing to the strong light-matter coupling of excitons in 2D semiconductors, we observe unambiguous signatures of confined exciton wavefunctions in optical reflection and photoluminescence measurements. Our work introduces a new approach to engineering exciton dynamics and interactions at the nanometer scale, with implications for novel optoelectronic devices, topological photonics, and many-body quantum nonlinear optics.