if we join namaz of magrib in 2nd rakat of jamat then what are the rules regarding jamat

Walaikumussalam
Make the niyat either in qyam or rukoo it will be consider as your first Rakat and while imam and others they recite tashahud at that time recite for the niyat of sawab only
When imam stand for third Rakat it will be your second Rakat therefore you recite sura hamd and one small Surah and qunoot and do rukoo and sajda with imam and read tashahud and then stand up for your third Rakat and complete your prayer.
Wassalam