You have to use either a uniform or an attribute; there is nothing “in between” the two in WebGL, and other possible implementations are in the end going to depend on uniform or attribute (or constant) data.
If you use a uniform, you can set the dash pattern for all the lines in a draw call, but not individual lines within it.
If you use an attribute, you must duplicate the selection of dash pattern for each vertex in the line. This is no different than the usual handling of e.g. colored lines, where you must give the (same) color at each vertex.
If your concern is total data size, you could do an indirection such as storing several dash patterns in a uniform array or a texture, and then using an attribute to lookup the desired pattern. This would allow you to use one number instead of four per vertex.