Do it when overnight (or any time frame that usually is not that busy), perhaps schedule and announce a maintenance downtime.
At least PostgreSQL knows an option to not lock the table but advises to not use it ;):
When this option is used, PostgreSQL will build the index without taking any locks that prevent concurrent inserts, updates, or deletes on the table; whereas a standard index build locks out writes (but not reads) on the table until it’s done. There are several caveats to be aware of when using this option — see Building Indexes Concurrently.
I do not know how other DBMS handle creating an index, but I’d assume that a write-lock applies, at least.