Can they, yes.
Do they any/every time you sign in to the App Store, I think not.
Apple would probably be able to collate your device's anonymous and unique ID with your Apple ID if you opt in or agree explicitly to a question that informs you that the serial number will be checked to verify eligibility for a specific product.
You might capture the serial number to iCloud if you are opting into trusted devices, two-factor authentication or find my iPhone / find my Mac. It's debatable whether Apple actually links that serial number to your account though, since they could stored in the way that let's you retrieve your serial number from all the possible ones as opposed to just storing it directly in the database.
Also, your question is extremely broad due to the fact that Apple ID can be used windows, on web browser sessions, on iOS devices, Mac devices, on airport devices, and on AppleTV space (currently). Furthermore, AppleID can be used with far more services than just the App Store so as you see with iCloud, it can get more complicated than yes/no.
On operating systems, Apple provides a security and privacy preference that allows you to opt in to sharing diagnostic information which could under some circumstances include serial number. More recent OS include a randomly generated GUID to help anonymize reports. You also can regenerate that ID on-demand on IOS to further enhance your privacy.
Apple has clearly stated many times on the record that they wish to collect as little customer data as possible, and retain that data for short periods only. Apple appears to minimize even further personally identifying information and that the consumer should clearly opt into these collections.
From where I sit, Apple has delivered on those promises in the software they design and ship. I also think your question is an extremely valid one, we all should be thinking so clearly as you are about the information we routinely provide to large corporations and how it either allows them or prevents them from invading our privacy and selling us out to the highest bidder.