Pattern calls for 280 CO sts, but I only have enough for 240. Can I just tie some more yarn onto the remaining yarn to get the last 40?
Yes, but how will you keep knitting if you don't have more yarn attached anyhow?
Did you cut the yarn to length in order to do your CO? If so, you don't need to do that. Just CO from the skein, and then keep right on knitting.
I'm assuming that one tail is too short. You can add yarn, but you don't want to knot it.
I don't know how it will show too much for 40 stitches, but I've switched to knitted cast on if I'm a few stitches short--only used one strand.
If you're doing long tail cast on that can happen if you underestimate how much you need.
One thing you can do to start with is to use 2 skeins or both ends of the skein to cast on. Take the two ends and knot them together then put one end over your thumb and one end over your fingers in the long tail position. Then just cast on what you need and cut one end leaving a 6-8 inch tail. Use the other yarn that is attached to knit with. When you're all done you can take the knot out of the one end and weave in all the loose ends.
Did you run out on the thumb yarn tail? You can use the cable CO to get the other 40 sts on. Chances are when you're done, it won't show.