British children used this term to ridicule a person who acted "yellow" or displayed signs of fear. As for custard, this British delicacy has been around since the 14th century. In fact Bird's Custard, established by Alfred Bird in 1837, remains the number one custard powder sold in the UK.
In 1899, Percy B. Green included this rhyme in A History of Nursery Rhymes:
"Cowardly, cowardly custard, Eats his mother's mustard."
Both custard and English mustard are yellow.