This is not possible in the form language. But you can assemble the action of a matrix and get a vector. Then you use this to set the diagonal of the matrix.
mass_form = v*u*dx()
mass_action_form = action(mass_form, Constant(1))
M_lumped = assemble(mass_form)
M_lumped.zero()
M_lumped.set_diagonal(assemble(mass_action_form))