I am an undergraduate engineering student. Last summer I was working on a project in a lab that was not particularly novel - it had already been published by another group, and it mainly involved implementing that group's results with minor changes. This summer, I have been given the opportunity to work in a different lab. I presume that I will be given the opportunity to discuss various projects with the professor when this job begins. At that time, is it appropriate to ask whether I can contribute to a publication, and if so, what is the most tactful way to do so?
There is nothing wrong with asking about the contribution to a publication. This shows your interest and that you will work for it. Also, you have nothing to lose. Think what's the worst that can happen if you ask! They'll say no, right? So, what happens if you don't? You still won't get the experience you want and the publication! So, your best bet always is to discuss your interest.
How to ask? Just show your interest in the project and that you are willing to work for it. Since you are an undergraduate student, you may face some skepticism at first, but if you show dedication, that'll prove your sincerity.