Depending on the medication and subject to the laws of the state you are traveling from and to, the answer is usually yes. Some states do not allow you to transfer your prescription back to your home state though, and for controlled substance prescriptions the situation on the ground even more stringent in particular states.
Legally speaking, you can fill prescriptions from one state and fill them in a different state. It is at the discretion of the pharmacist if they feel comfortable doing this. If it is just some simple medication, it should be no problem at all. Pharmacist may choose to call and verify the prescription if he/she feels less comfortable filling any controlled substances from out-of-state. Some hospital pharmacies only fill scripts from specific doctors.
In any case, each state has its own little nuances so it is always a good idea for patients to firstly informatively call a pharmacy in the state they are headed to and ask if they take out-of-state prescriptions. It is also a good move to take the script to the pharmacy at a time when your prescriber is usually in the office so the verification can go faster and easier.
Various experiences have shown that if you use a multi-state pharmacy chain like CVS or Walgreens in the US, your prescriptions can usually easily be transferred or filled by a branch in another state.
Generally speaking, non-controlled substances are not an issue when it comes to the question can I fill a prescription in another state. Controlled substances is where the situation gets messier. You should not take a chance with Class II medications. Fill them in your home state. Have even other controlled medications preferably filled in your home state to be on the safe side.
Complications usually happen with insurance and state laws with out of state providers.
It often happens when you travel to another state that a pharmacy is not contracted to process your insurance, particularly in those cases when your benefits are provided through state assistance. In such cases you may often find there is simply no way to gain access to any benefits, medical or pharmacy, when out of state and no vacation allowance is covered for early refills. Most private insurance companies, on the other hand, will allow you to get an override for an early refill for vacation purposes, which has to be requested by the pharmacist filling the prescription.