I don’t know why would you create a barcode, but since I keep seeing them used here and there, why not? (for example, you can create a “product” using a picture, create a box, and finally add a barcode to it, but we’ll talk only about the barcode, now)

Creating a Barcode Graphic

1. Create a new image, using any settings you want. You can add the barcode to a new layer over an existing image, or create a new document only for it. See my settings below…
Creating a Barcode Graphic
2. Using the Pencil Tool, draw a black line on a new layer. Make it 1 pixel thick, and be sure to hold Shift to be straight.

Creating a Barcode Graphic

3. Apply Filter>Noise>Add Noise, with the settings below.

Creating a Barcode Graphic

4. Press Ctrl+T and stretch this line to turn it into a bar.

Creating a Barcode Graphic

5. If you want to play with this, you can use the Levels control and drag the white or black sliders all the way to left or right. Below, you can see the result of pushing the black input levels to max.

Creating a Barcode Graphic

Now, that you have the barcode, you can play with it, maybe add some numbers, or create a label inspired by a certain product.