From Hardee’s Rifle and Light Infantry Tactics, regarding daily rations:
Looking at the soldier’s rations, note the specific inclusion of green coffee beans. At the time, most Americans typically roasted their own beans over a fire. While there were dedicated roasting pans and other self-contained roasters, those would have been luxuries in the Frontier, and completely untenable for someone on the trail. For the sake of convenience roasted but whole coffee beans would have been preferred for anyone going on the trail, but green beans would have been cheaper, and roasting them would just be another part of the cookie’s duties. Of course anyone living in a town would have almost always roasted their own green beans.
Regardless of whether the beans came roasted or green, they would have been ground in situ, preground coffee not being a thing at the time. Hand crank coffee grinders were a relatively normal household item of the era. Typical grinders of the time can still be found in antique stores – some meant to be used on a tabletop, while others were designed to be mounted on a wall. The small handheld ones which would be used on the trail are actually still reasonably common today. Ironically, as these were burr grinders they gave a more consistent grind than the modern blade grinders many people use. This kind of coffee grinder might today be sold as a pepper mill or Turkish coffee grinder, but at the time was just a coffee grinder.
Once the coffee was ground, it could be brewed. We tend to assume cowboys used percolators like the ones campers use today, but this is unlikely. The modern percolator was only invented in 1819, and the stove-top percolator was patented in 1889. Most likely this kind of dedicated apparatus was impractical and not used by most people in the “Old West”, especially not by cowboys on the trail, where a simpler pot would suffice. (It is worth noting that many stovetop percolators use the same kind of tall, conical kettle as was popular from this era, which became synonymous with the stovetop percolator.)
Instead, as described elsewhere, they brewed in a method often described as “cowboy coffee”: simply stir ground coffee into boiling or near-boiling water and remove from heat to let it brew. A little cold water could be added to settle the grounds, and then a deft hand could pour the coffee without getting too much ground coffee in the cup. This method of brewing, unintentionally, is very similar to the traditional method used to brew coffee in Ethiopia and the resultant drink is not too different.
Bear in mind when considering this, that there was no one “right” way to make coffee (or any other foodstuff). Most cooking techniques had not been formalized and especially in the American frontier a cook learned from a parent or as an apprentice, not as a result of formal training. Each person making coffee had their own technique or style, so there was plenty of variation.