In the United States, Title IX of the Education Amendments of 1972 prohibits sex-based discrimination in federally funded education programs, including athletics. This means girls are allowed to play on boys' basketball teams as long as there is no discrimination based on sex.
Some states may have additional regulations, so it's best to check with the local school district for eligibility. Note that men's and women's games have different rules (ball size, three-point line, etc.), which may affect participation.