Extremal graphs for threshold metric dimension