The problem with uniform identification is often resolution.
If these collar insignia were clearly distinguishable, identification could be simplified. This emblem however, is not clear enough to make any definitive unit designation (at least for me).

One thing we can see adequately is the rank marking on the shoulder.


The image on the right from Wikipedia shows this individuals rank was the equivalent of Staff Sergeant, depending on his unit again:
Staff sergeants can also hold other appointments, such as company
quartermaster sergeant, and are usually known by that appointment if
held. The equivalent rank in infantry regiments is colour sergeant,
and holders are known by that title no matter what their appointment.
In the Household Cavalry the equivalent rank is staff corporal.
Trying to track down units that were stationed in Ranikhet around 1920 provided some conflicting results, with several units in and out of the region in the WW1 and Interwar timeframe.
This still doesn't give us a unit yet, but if we add in a little genealogical research, we might get lucky. Trying to find records of your ancestor directly, I clicked on an ad for a site called Forces War Records, which offered access to British military records. Surprisingly, searching was enabled before the site started asking for personal information. Searching for John P Lockton originally brought up many pages of matches, but limiting the search to the Interwar time period, brought only six results, with one being a Staff Sergeant:

A little research into the Supply and Transport Corps, lead to this information in Wikipedia:
The origin of the corps go back to 1760 when a Commissariat used to
exist in the administrative component of the armies three Presidencies
of Bengal, Madras and Bombay. In 1878 the separate Commissariats were
amalgamated into a single entity and then in 1901 it was renamed the
Supply and Transport Corps. During the First World War the corps
became a permanent component of the British Indian Army and was
renamed the Indian Army Service Corps in 1923. In 1935 the corps was
granted the 'Royal' prefix and became known as Royal Indian Army
Service Corps (RIASC).
So, this looks to be a possible match to your ancestor.
When trying to connect the evidence we have, I looked for a unit badge for the Supply and Transport Corps,and found several images, one from a Pinterest page, looks like this:

I can't tell, perhaps a match to the fuzzy image above, perhaps not. As I said, photo resolution is often the main problem for identification questions here...
I hope some of this may help, and if you wish to enter your info into the records site, you may be able to learn more.