Aims. We study the polarization of hard X-ray (HXR) sources in the solar atmosphere, including Compton backscattering of photons in the photosphere (the albedo effect) and the spatial distribution of polarization across the source. Methods. HXR photon polarization and spectra produced via electron-ion bremsstrahlung emission are calculated from various electron distributions typical for solar flares. Compton scattering and photoelectric absorption are then modelled using Monte Carlo simulations of photon transport in the photosphere to study the observed (primary and albedo) sources. Polarization maps across HXR sources (primary and albedo components) for each of the modelled electron distributions are calculated at various source locations from the solar centre to the limb. Results. We show that Compton scattering produces a distinct polarization variation across the albedo patch at peak albedo energies of 20-50 keV for all anisotropies modelled. The results show that there are distinct spatial polarization changes in both the radial and perpendicular to radial directions across the extent of the HXR source at a given disk location. In the radial direction, the polarization magnitude and direction at specific positions along the HXR source will either increase or decrease with increased photon distribution directivity towards the photosphere. We also show how high electron cutoff energies influence the direction of polarization at above ∼100 keV. Conclusions. Spatially resolved HXR polarization measurements can provide important information about the directivity and energetics of the electron distribution. Our results indicate the preferred angular resolution of polarization measurements required to distinguish between the scattered and primary components. We also show how spatially resolved polarization measurements could be used to probe the emission pattern of an HXR source, using both the magnitude and the direction of the polarization.