You say I cannot use the obvious:
sample(mydf[mydf$gender == "F", ], 3)
but you could write your own function for doing it:
sample.df <- function(df, n) df[sample(nrow(df), n), , drop = FALSE]
then run it on your subset selection:
sample.df(mydf[mydf$gender == "F", ], 3)
# gender age
# 5 F 31
# 4 F 29
# 1 F 23
(Personally I find sample.df(subset(mydf, gender == "F"), 3)
easier to read.)