We study ground-state properties and dynamics of a dilute ultracold atomic gas in a double-well potential. The Gaussian barrier separating the two wells derives from the interaction between the atoms and a quantized field of a driven Fabry-Perot cavity. Due to intrinsic atom-field nonlinearity, several interesting phenomena arise which are the focus of this work. For the ground state, there is a critical pumping amplitude in which the atoms self-organize and the intra-cavity-field amplitude drastically increases. In the dynamical analysis, we show that the Josephson oscillations depend strongly on the atomic density and may be greatly suppressed within certain regimes, reminiscent of self-trapping of Bose-Einstein condensates in double-well setups. This pseudo-self-trapping effect is studied within a mean-field treatment valid for large atom numbers. For small numbers of atoms, we consider the analogous many-body problem and demonstrate a collapse-revival structure in the Josephson oscillations.