OCI can be applied in India. but you should be a long term visa. Some places it says you need 3 months validity remaining and some say 6 months validity in existing visa. So in nutshell it can be done if you can arrange a longer term entry visa to begin with.
Foreign nationals cannot apply for OCI in India while on Tourist Visa, Missionary Visa and Mountaineering Visa. Moreover, the foreigner has to be ordinarily resident of India to be eligible to apply for OCI registration in India.
Note: 'ordinarily resident' will mean a person staying in a particular country or in India for a continuous period of 6 months.
https://ociservices.gov.in/
One more thing. I believe OCI has to be applied in FRRO offices (popup from above site shows locations) and because of covid i think now they need appointments to visit the office. So you may have to factor in that as well.
Thank you