Let's assume you have CG1 scalar function u
and local expansion coefficients coeff
being numpy array ordered according to local vertex indexing.
V = FunctionSpace(mesh, 'CG', 1)
local_range = V.dofmap().ownership_range()
num_local_dofs = local_range[1] - local_range[0]
u = Function(V)
coeff = numpy.zeros(num_local_dofs)
Then
u.vector().set_local(coeff[V.dofmap().vertex_to_dof_map(mesh)])
u.update()
For a vector valued function it may require little modifications.