Yes, some languages are actively discouraged from being learned by outsiders, often due to cultural protection, historical trauma, or social norms. Examples include Pueblo languages like Hopi, certain Indigenous languages in Australia and the Americas, and some minority languages in Africa where speaking with outsiders is seen as inappropriate or taboo. The key is to recognize that this reluctance is not about the learner, but about the community's right to control their linguistic heritage.
In many cases, the discouragement stems from a history of colonization, forced assimilation, or cultural appropriation. For instance, some Native American tribes view their languages as sacred and not to be shared with outsiders, while in parts of Sub-Saharan Africa, certain ethnic groups may avoid using their L1 with foreigners to prevent social friction or to maintain linguistic purity. The example you recall likely reflects a community where using the local language with a white person was seen as crossing a social boundary, not a reflection of the learner's skill.
If you encounter such a situation, respect the community's wishes. Do not insist on speaking their language if they prefer a colonial or lingua franca. Instead, show genuine interest by learning about their culture, asking permission to learn a few words, and being patient. Some communities may have open language revitalization programs, while others may remain closed. Research the specific group's attitudes beforehand; academic sources, language documentation projects, or community-run websites can provide guidance. Avoid making assumptions based on broad categories like "indigenous" because each group has unique norms.
Tradeoffs: Pushing to learn a discouraged language can damage relationships and reinforce negative stereotypes. However, some communities welcome outsiders as allies in language preservation if approached with humility and respect. Your best next step is to learn about the specific community's history and current language policies, then follow their lead. If they say no, accept it gracefully and support their efforts in other ways, such as advocating for their language rights.