The answer is "it depends".
Whether we're talking changing one's biological sex, or having sex, the age at which society grants adulthood is completely arbitrary. There's nothing biological that changes once someone reaches their 18th birthday (or 21st or 16th). We act like there's a difference between an 18 year old and a 17 year old, but there isn't. They're no more or less capable of making decisions on their 18th birthday than they were the day before.
There's only 2 objective places you could put that line, which would be either once the person reaches puberty, or at age 25(ish) once the person reaches full intellectual maturity.
As soon as one establishes that adulthood happening at age 18 is arbitrary, the question "can minors consent" takes a different meaning. Because a "minor" is just a person under the legal age of adulthood, which means nothing except that a government regulates them differently once they cross that threshold. The capability for consent doesn't correlate to "adult" status vs. "minor" status.
What actually makes someone capable of consent is their own personal physical, sexual, and mental development, which could be fully formed by age 13, or it might not be developed even by age 25. The laws regulating adulthood function more as a pragmatic attempt to protect young people, since the majority of young people are not physically or mentally capable of understanding what goes into consent. In general, younger people probably can't consent, so the law attempts to help them out, but you still have to differentiate between personal knowledge of self, which actually defines capability for consent, as opposed to the legal age of adulthood.