You can definitely do that! The yarn I recommend in the pattern is ALWAYS just a yarn suggestion. You can easily find something else. Remember, however, that the finished result can always vary slightly depending on which yarn you use.
First look at the knitting tension - it's important! Choose another yarn that can meet the same knitting tension as the yarn I used. If there is no knitting tension mentioned on the yarn, also look at the running length. Here you can often get an indication of whether the thickness of the yarn is the same as the one I used. Note that the running length can only be used for comparison if the yarn's fiber composition is roughly the same. For example, you can't compare a running length of wool and cashmere, as cashmere is very light, so here it's safest to go by the recommended knitting tension.
If you want to achieve a result that is as similar as possible to what I have knitted, then in addition to the same knitting tension, you should also go for the same fiber type or one that is similar. A sweater knitted in, for example, Norwegian wool will look different in pure cotton. But as long as the knitting tension is right, it should fit the measurements.
Always remember to do a test stitch. Especially if you knit in a different yarn, you can't count on the needle size I recommend (but always be sure and do a test stitch no matter what - we all knit differently).
Read more about replacing yarn right here.