Dual-unitary quantum circuits can be used to construct 1+1 dimensional lattice models for which dynamical correlations of local observables can be explicitly calculated. We show how to analytically construct classes of dual-unitary circuits with any desired level of (non-)ergodicity for any dimension of the local Hilbert space, and present analytical results for thermalization to an infinite-temperature Gibbs state (ergodic) and a generalized Gibbs ensemble (nonergodic). It is shown how a tunable ergodicity-inducing perturbation can be added to a nonergodic circuit without breaking dual unitarity, leading to the appearance of prethermalization plateaux for local observables.