The assignment of hybridization and molecular geometry for molecules that have two or more major resonance structures is the same as the process for a single Lewis structure. There is one caveat: the hybridization (and hence molecular geometry) assigned to one resonance structure must be the same as all other resonance structures in the set. This is because a set of resonance structures describes a single molecule.
Therefore, when assigning hybridization, you should consider all the major resonance structures. If an atom’s nhyb is different in one resonance structure from another, then use the smaller nhyb to determine hybridization.
In formamide, the delocalized π molecular orbital extends over the oxygen, carbon, and nitrogen atoms (see figure below). This is also described by the set of resonance structures, where there is a partial double-bond character between O and C as well as between C and N. An unhybridized 2p atomic orbital on the N atom must contribute to this π bond. Therefore, the N atom must have sp2 hybridization (it forms three σ bonds) and a trigonal planar local geometry. If N had an sp3 hybridization, it would not be able to participate in the π bond.
When looking at the left resonance structure, you might be tempted to assign sp3 hybridization to N given its similarity to ammonia (NH3). However, this is a resonance structure; the set of resonance structures describes a molecule that cannot be described correctly by a single Lewis structure. All atoms must remain in the same positions from one resonance structure to another in a set of resonance structures. There cannot be a N atom that is trigonal pyramidal in one resonance structure and trigonal planar in another resonance structure, because the atoms attached to the N would have to change positions.
Experimental evidence and quantum mechanics calculations show that formamide is a planar molecule, hence, the hybridization and geometry assignments are valid. This also means that the planar geometry must be more stable than the geometry involving a trigonal pyramidal sp3 N. In other words, participation in the π bonding stabilizes the sp2 hybridization of N.