By getting metadata from some pdf files with bookmarks by pdftk, I observe the format of bookmarks in pdf metadata. So I am guessing that with pdftk, it is possible to add and edit bookmarks of a pdf file.

Here are three steps that I follow:

I firstly get the metadata (including bookmarks if any) from a pdf
file into a text file by pdftk in.pdf dump_data > in.info.

Next I add some bookmarks into the metadata text file in.info, changing it
from

As far as I understand, bookmarks as per the PDF spec can't be injected via a diagnostic tool like pdftk. Updating the metadata to refer to chapters and bookmark landing anchors that don't exist will definitely not work, it may even make your PDF inconsistent or unopenable.

I ended up using java+iText libraries to do what you're suggesting as per this tutorial, but we're dealing with hundreds of pdfs daily, so it needed to be automated. If you're doing a one-off, Adobe Acrobat should be able to do this.

There is bmconverter project on GitHub that can convert various PDF bookmark formats. It can convert pdftk output to jpdftweak format, although if you will use jpdftweak then you wont need to convert pdftk output to csv, as you can do all work from within jpdftweak.

Unfortunately pdfmarks is not supported by the project, but fortunately someone posted script in bmconverter issues that can convert pdftk output to pdfmarks. So ghostscript batch option is an option