Yes — candidates in the final year of their degree can apply for the UPSC prelims.
You must be able to produce proof of passing the degree when applying for the mains.
The degree certificate or marksheet is checked during the detailed application stage.
If you cannot produce proof by the mains application deadline, your candidature is cancelled.
Check the notification for the exact cut-off dates each year.