For pedagogy's sake, here is a functional way to do it. np.where actually does exactly what you want, but the tricky part is that it accepts a boolean condition, not an index:
f(np.where(condition, 43, m1))
which sends 43 to f wherever condition is met, elsewhere it just sends m1, so this would likely be simpler if we knew your criteria for choosing the element to change. As such, the trickiest part is creating the boolean array, which is a bit wasteful anyway.
np.where(np.all(np.indices(m1.shape) == np.array([2, 7])[:, None, None], 0), 43, m1)
or equivalently:
np.where(np.all(np.rollaxis(np.indices(m1.shape),0,3) == np.array([2, 7]), -1), 43, m1)
I could have sworn there was an equivalent function that took an index instead of a mask, but unfortunately it seems the similar functions (np.put, e.g.) that take indices modify the array in place, instead of returning a new one functionally. np.choose would also work but has the same issues of creating a "choice" array (as opposed to a condition mask array).
In action:
In [66]: m1 = np.zeros((4, 9))
In [67]: np.where(np.all(np.indices(m1.shape) == np.array([2, 7])[:,None, None], 0), 43, m1)
Out[67]:
array([[ 0., 0., 0., 0., 0., 0., 0., 0., 0.],
[ 0., 0., 0., 0., 0., 0., 0., 0., 0.],
[ 0., 0., 0., 0., 0., 0., 0., 43., 0.],
[ 0., 0., 0., 0., 0., 0., 0., 0., 0.]])
In [68]: np.where(np.all(np.rollaxis(np.indices(m1.shape),0,3) == np.array([2, 7]), -1), 43, m1)
Out[68]:
array([[ 0., 0., 0., 0., 0., 0., 0., 0., 0.],
[ 0., 0., 0., 0., 0., 0., 0., 0., 0.],
[ 0., 0., 0., 0., 0., 0., 0., 43., 0.],
[ 0., 0., 0., 0., 0., 0., 0., 0., 0.]])
m1andm2in same time, there might be a more elegant and efficient way to do so.