A dad-of-two who claimed his harassment of a lone female passenger on a train was just “banter” has been sentenced in a legal first.