To specify NBT for an ingredient, use an ingredient of type minecraft:item_nbt and specify the NBT data in the "nbt" property.
To specify NBT for a result, simply specify the NBT data in the "nbt" property.
You can see an example of a recipe that results in a spawner here.