Flags, coat armor and caparisons were often painted in the Middle Ages, and Cennino Cennini had much useful advice on painting cloth. Both silk and linen was used for surviving flags, and the Earl of Wawick owned standards of worsted. Cennini also described how to paint velvet, and woolen cloth for jousts or tournaments. Cennini generally sized the cloth where it would be painted, which is essential to protect the cloth if oil based paint or mordant for gilding is used.
Modern acrylic fabric paint can be applied to cloth directly, but has a gloss that is somewhat different from oil paint over size or tempera.
My most recent flag project was a silk pennoncel, with three gold sandglasses on a blue field. Fabric paint was the lowest layer of the sandglasses, with gold leaf burnished atop that with gum arabic.
Using resist and dyes to paint silk seems to have been unknown in Europe before the 19th century.