If someone claimed divinity, to be worthy of worship, or to be Allah, or something like this, and repented sincerely to Allah before death, would Allah forgive them? What should a person do if they did such? And why did Allah not accept the Tawbah of Pharoah? Was it cause it was too late for him?

Ustadh AbdulAziz al-Haqqan
If somebody repents, Allah accepts from him, and Allah knows best what is inside his heart. As for Fir'aun (Pharaoh), yes, because it was too late.