I would break each octet apart, and remove any leading zeroes from each, then concatenate them together. Something like this:
str="$five_digits"
if [[ ${#str} != 5 ]] || [[ ${str:0:2} != "12" ]]; then
echo invalid input >&2;
exit 1;
fi
a=10 # first octet, constant
b=${str:2:2} # second octet
b=${b#0} # remove one leading zero
c=${str:4:1}9 # third octet
c=${c#0} # remove one leading zero
res="$a.$b.$c" # concatenated result
echo "$res"
E.g. that turns the input string `12345` to `10.34.59`; `12055` to `10.5.59`; and `12000` to `10.0.9`.