We present a non-perturbative direct method to calculate the polarizability of a hydrogen atom confined in a three-dimensional potential well of any geometry. The calculation is based on the diffusion Monte Carlo method. The advantage of the method is simplicity of implementation and immediate adaptability to any well shape. The method is validated for the well-studied spherically confined hydrogen atom, and demonstrated in the case of two other geometries (cube and octahedron), for which this paper provides the first set of results. Although demonstrated here for the confined hydrogen atom, the method can be immediately applied to any single-electron system placed in a three-dimensional potential well of any type and geometry. The application of the method to hydrogen atoms confined in potential wells of cubic or spherical symmetry suggests as a result that the polarizability of the system in these cases is a universal function of the volume of the well. This result can simplify calculations for real situations such as in quantum dots.