Is there a way to create a barcode in InDesign?
Only with third-party software.
There are a number of free barcode generators that work with some formats, with varying degrees of success. A quick Google search will inform you of a lot of them.
But if you're going to do this kind of work a lot, or work with a number of different formats, I recommend BarcodeMaker from Teacup Software. It's not cheap, and it has gone to a subscription product, but it's the best barcode generator I've found.
Hope this helps,
... And, Funny! it is totally scriptable!
(^/) The Jedi
Do tell. You want to share that with us?
Barcode? What type of barcode?
I've done barcodes in the format 39 30+ years ago by using a barcode font.
Maunly EAN barcodes.
For EAN code look into this product by Marc Autret:
BookBarcode 2.039 Supports New ISBN Ranges
Marc Autret, June 18, 2021
Hope, it will fit your needs.
( ACP )