The night train from Tbilisi to Baku reaches the border around 2 hours after leaving Tbilisi.
Then, the police gets in and collects everyone's passport. Your bag will be searched for any item related to Armenia (Book, flag, clothes, tickets, etc) and you'll be asked if you ever went to Armenia.
If you're neither Georgian or Azerbaijani you'll be taken to an empty compartment for the formalities (taking your pictures, giving you back your passport and possibly asking you one or two questions).
Azerbaijan and Armenia are in conflict over the Nagorno-Karabakh territory and the relations between the two countries are very tense.