In theory, of course, physicians (at least where I live) are prohibited by law from answering such requests. In practice, it seems such things were sometimes done.
As long as the girl is a minor, I suppose parents can have a doctor perform a general examination and then, 'en passant', check the virginity status. very simple to workaround. Parents probably needn't even specifically request a virginity check, just ask for a general (sexual) health assessment, say they have fears of possible STDs.
And if the girl is an adult and still living at home and does comes along, well, in theory, no one can force her to come, so parents can always say she was in agreement.
Btw, I read in several historical biographies, that certainly up until the 1930s in certain European countries, it was not uncommon for boarding school girls, upon graduation, be examined for their virginity status so that (usually nun-run) boarding schools (for the higher classes) could offer proof of virginity and by extension, prove they took good care of the girls. This may not have been a very practice, but it was done nonetheless in some milieus. I have read this in very reputable books by serious historians.