You're going to want to use the zeropad system expression to add leading zeroes.
zeropad(number, digits)
Pad number out to a certain number of digits by adding zeroes in front of the number, then returning the result as a string. For example, zeropad(45, 5) returns the string "00045"
For changing a 24 hour format to a 12 hour format, use modulo %, which is the remainder after dividing. Note that "0" should actually read 12 in this case, so you could add a conditional expression
This reads "If the remainder of hours after dividing by 12 is 0, then 12, else the remainder of hours after dividing by 12."
Adding zeropad to that would look like this -
hour%12=0?12:zeropad(hour%12,2)
And it is always a good idea to int() or round() to account for rounding errors -
int(hour%12)=0?12:zeropad(int(hour%12),2)
To determine AM or PM for the hours, divide hours by 12. 0-11 are AM, and 12-23 are PM. You can use another conditional expression -