Yes! you can buy travel insurance at the last moment. There are many travel insurance providers, from where you can choose according to your requirement. Allianz Global Assistance, World Nomads, Travel Guard by AIG.
All the insurances have different benefits (medical coverage, trip cancellation), so it’s better to go through each insurance and compare them and then decide the best insurance for you.