Atomic UPDATE to increment integer in Postgresql
Yes, that is safe.
While one such statement is running, all other such statements are blocked on a lock. The lock will be released when the transaction completes, so keep your transactions short. On the other hand, you need to keep your transaction open until all your work is done, otherwise you might end up with gaps in your sequence.
That is why it is usually considered a bad idea to ask for gapless sequences.
Unless I misunderstand the question, that's what the SERIAL data type is for:
https://www.postgresql.org/docs/8.1/static/datatype.html#DATATYPE-SERIAL