When creating a lattice, you can set a custom matrix. So you can input your own. You just have to make sure you set the matrix of both the lattice and its base.
import pymel.core as pm
selection = pm.selected()
for mesh in selection:
matrix = mesh.matrix.get()
lat = pm.lattice(divisions=[2,2,2])
for x in lat[1:]:
x.setMatrix(matrix.matrix)
x.scale.set(x.scale.get()*100) # the scale is just the conversion to meters, since my Maya is set to meters
I found this a really long time ago, which might also be of interest to you.
And if you want to make a “custom lattice”, have a look at Maya’s wrap deformer