You learn by doing! The idea of publishing is really scary, but that's why we get 6 years to master how to do it! Every lab is different, but you may start as a co-author for your first one so you can be a part of the process and see how it goes and how your mentor wants and does things before you do it yourself. And in most/all the programs I applied to, they encourage students to use data or part of a paper required for coursework to turn into a publication because you get a lot of help and feedback throughout that process. You're not expected to do it alone, that's why we have mentors and older grad students to guide us :) Not knowing how to go about things like this scares me too, but every faculty I've spoke with throughout my app process has assured me that you don't need to know everything/most things coming into this, because that is what 6 years of grad school is for. That's why programs have writing classes and research methods courses and a required empirical master's thesis, as it gives you scaffolded assistance so when you write your dissertation, reading and writing and hypothesizing is second nature. Keep calm my friend, you got this!