This code will do what you want:
minsign = M_top__z if abs(M_top__z) < abs(M_bot__z) else M_bot__z
M_01__z = min((abs(M_top__z), abs(M_bot__z))) + N_Ed*e_0__z
if minsign < 0:
M_01__z *= -1
print(F"{minsign = } {M_01__z = }")
Even though the printed answer is mathematically incorrect.