It should work: the variable is ordinal so using numerical values makes sense.
So there's a bug somewhere, here are a few suggestions of things to look at:
Possibly a type conversion error somewhere: make sure the variable is interpreted as numerical.
Check whether the model actually uses the variable: if not then it's likely some type error; if yes then I ...
If tf dataset is used you cannot use the class_weights parameter. Insted return the weight from a parse_function in your pipeline
weight_arr = [1.5, 0.5] #define your custom weights
#create a lookup table
key_tensor = tf.constant(list(range(0, len(weight_arr))), dtype=tf.int64)
val_tensor = tf.constant(weight_arr)
init = tf.lookup....