There seem to be 3 different ways to learn this:
If a user has no idea exactly how his fruit can be used, he can play around with different motions movements or just live his life. Brook never figured out what his fruit could do until he was already dead. Hypothetically, Bartolomeo could have lived his life without finding out if he hadn't happened to cross his fingers the right way (assuming that is required).
Some users have some idea what their fruit is when they eat it. Others only have partial knowledge of their abilities. The Barrier Fruit is based off a children's game. If Bartolomeo knew that he had this fruit, they could have tried to enact that game to see if it worked. This can be combined with experimentation to improve fruits. Bartholomew Kuma and Law seem to have decided to try appying their abilities to abstract concepts and studied their ability to learn how to do this. Other fruits may have simular unusual uses that are never noticed as the users aren't as smart as those two.
Devil Fruits are not single use. They are reincarnated into a new fruit to be eaten when the user dies. This means, for instance, that Law knew exactly what fruit he had before he knew how to use it. There are records and second/third hand sources stating what some fruits can do. That is exactly why he knows that you can make someone immortal with it despite having never done so. For our repeated example, Bartolomeo might know he has to cross his fingers because he could have read that it was required. This means, of course, that someone else must have learned it by on of the first two methods and there may be other unknown uses.
Devil Fruits do not change during the person's life (with Brook as the possible exception). A Logia fruit does not itself get stronger as the user does but the user can get more creative, more practiced, and more experienced in combat in general. This means that training can't make the fruit itself more powerful or generate new powers that previously were impossible (only undiscovered).