I can give you an example where it works best. Reddit.
I find reddit very much functional, if not always beautiful. They have found their high performing sweet spot.
Their home page offers a global search. When you click on the search box, the site slides out an advanced search panel. Let us ignore for now. But in general the global search searches across all subreddits (reddit sub pages or communities) and fetches all the relevant results.
As you enter any of the subreddit (internal community page) the behavior changes and the site offers a small quick check if the user wants to limit the search to the community.
So it is very much possible to provide different functionality of search in the inside pages of the site. However, you should take efforts to educate users about this change. In case of reddit, the variation is minimal and a simple check box is enough. Based on your requirement and the deviation from the global search, you might want to consider different ways to let the user know of the behavior change.
EDIT: My bad, I saw your request of mobile after putting my answer.
In case of mobile, you would want to pay attention to the way your page is structured. A global search is always expected to work on global results. So if your users title is below the search box (as the search is global) you will have to take extra pains to make sure your user is aware of these changes. I would not recommend such an approach as it breaks conventions.
If you instead have a Users page title above the search box, then it is not a global search any longer. Using effective ways of UI design you can make use of user's mental model and perception of hierarchy of elements to make sure that the sub pages have different implementations of the search.
If you want suggestions on the design approach, first we would need to see your current approach of UI design.