We propose a self-consistent site-dependent Hubbard $U$ approach for DFT+$U$ calculations of defects in complex transition-metal oxides, using Hubbard parameters computed via linear-response theory. The formation of a defect locally perturbs the chemical environment of Hubbard sites in its vicinity, resulting in different Hubbard $U$ parameters for different sites. Using oxygen vacancies in SrMnO$_3$ as a model system, we investigate the dependence of $U$ on the chemical environment and study its influence on the structural, electronic, and magnetic properties of defective bulk and strained thin-film structures. Our results show that a self-consistent $U$ improves the description of stoichiometric bulk SrMnO$_3$ with respect to GGA or GGA+$U$ calculations using an empirical $U$. For defective systems, $U$ changes as a function of the distance of the Hubbard site from the defect, its oxidation state and the magnetic phase of the bulk structure. Taking into account this dependence, in turn, affects the computed defect formation energies and the predicted strain- and/or defect-induced magnetic phase transitions, especially when occupied localized states appear in the band gap of the material upon defect creation.