We study pattern formation in a passive nonlinear optical cavity on the basis of the classic Lugiato-Lefever model with a periodically modulated injection. When the injection amplitude sign alternates, e.g., following a sinusoidal modulation in time or in space, a phase-bistable response emerges, which is at the root of the spatial pattern formation in the system. An asymptotic description is given in terms of a damped nonlinear Schr\odinger equation with parametric amplification, which allows gaining insight into the basic spatiotemporal dynamics of the system. One- and two-dimensional phase-bistable spatial patterns, such as bright and dark-ring cavity solitons and labyrinths, are demonstrated.