Yes, you can invest in foreign markets. There is a provision by SEBI, under which it allows certain foreign investors to invest in India, by the way of QFIs, that is, Qualified Foreign Investors. This has less number of rules and restrictions. Other ways by which foreign investors can invest in India are the mutual fund routes and the ETFs. There are a lot of India focused ETFs and mutual funds. Interested foreign investors can also have a look at these and invest in India.
For becoming a member registered under the QFI, you must get your KYC done, get a PAN number in India and deposit the required documents with the authorities. After you are registered, you can transact on delivery based transactions, however, they are not allowed to pursue intraday trade. For purchasing any shares, you need to have a prior approval of the concerned depositories.