Quick search found this on Flag Etiquette for funeral:
While on the casket, the union of the flag should be at the head of the casket over the left shoulder. When the flag is removed, it should not be allowed to touch the ground. It should be folded lengthwise twice so that the union remains visible. It should then be folded into triangles, starting from the striped end, and presented to the next-of-kin. When there is no next of kin, a friend may receive the flag, provided the friend makes application for the flag before the funeral. Under no circumstances should the flag be buried with the veteran.
https://classroom.synonym.com/the-flag-code-and-proper-flag-etiquette-for-funerals-12084747.html