Two methods spring to mind:
Try writing your own custom expression as explained here.
The other is to implement ufl conditional
s:
from dolfin import *
import matplotlib.pyplot as plt
import ufl
ufl.algorithms.apply_derivatives.CONDITIONAL_WORKAROUND = True
mesh = UnitSquareMesh(32, 32)
V = FunctionSpace(mesh, 'CG', 1)
T, v = Function(V), TestFunction(V)
# kappa = (T + 1)**2 if T > T_mid else 1.0
T_mid = Constant(0.01)
kappa = conditional(gt(T, T_mid), (T + 1)**2, Constant(1.0))
F = dot(kappa*grad(T), grad(v))*dx - Constant(1.0)*v*dx
bcs = [DirichletBC(V, Constant(0.0), 'on_boundary')]
solve(F == 0, T, bcs)
plot(T)
plt.show()