They can, but most people would prefer that they didn't.
Which people? Why?
I very much preferred it when basketball uniforms looked like this...
The basketball shorts are now so long and baggy, they look like skirts, or culottes. I don't find it at all attractive--not on boys, and not on grown men.
Do boys have to wear long baggy bathing trunks too? Can't a boy wear short bathing trunks?
I think boys shorts now look like it would take 3 more years, and another 20 pounds, for the wearer to grow into them.
The knee length look, or the covered knee look, in shorts, really isn't attractive on most people--neither males nor females.