  The cosmic evolution of the barred galaxy population provides key information
about the secular evolution of galaxies and the settling of rotationally
dominated discs. We study the bar fraction in the SMACSJ0723.37323 (SMACS0723)
cluster of galaxies at z = 0.39 using the Early Release Observations obtained
with the NIRCam instrument mounted on the JWST telescope. As already found in
nearby galaxy samples, we find that the bar fraction distribution of SMACS0723
is a strong function of the galaxy stellar luminosity/mass. The analogy with
local clusters, such as Virgo and Coma, reveals a similar distribution among
the three clusters for low-mass galaxies (log(M_star/M_sun) \leq 9.5). The
comparison with a sample of local galaxies in a field environment shows a
remarkable lack of bars in this low-mass regime for the SMACS0723 cluster (and
therefore in Virgo and Coma) with respect to the field. At high masses
(log(M_star/M_sun) \geq 10.25), galaxies in SMACS0723 show a slightly lower bar
fraction than those in Coma. Our results support a scenario where cluster
environment affects the formation of bars in a mass-dependent way. At high
masses, the mild increase in the bar fraction of local clusters (Coma) with
respect to both SMACS0723 and local field galaxies suggests a weak effect of
cluster environment possibly triggering bar formation. On the other hand,
low-mass galaxies show the same bar fraction in the three clusters (different
redshifts) and a significant drop with respect to field galaxies at z=0,
therefore suggesting that: i) the bar fraction of low-mass galaxies in clusters
is not evolving during the last 4~Gyr, and ii) bar formation is severely
inhibited in low-mass galaxies living in clusters (Abridged).
