If the Auto-Complete Brackets/Quotation Marks option is set, you can simply type [.
However, I know you want to write a macro to process multiple selection scenarios. Here is an example:
sInsertBefore = "[";
sInsertAfter = "]";
var axT = [];
var ayT = [];
var axB = [];
var ayB = [];
Redraw = false;
CombineHistory = true;
nCount = document.selection.Count; // retrieves the number of selections
for( i = 1; i <= nCount; ++i ) { // loop through multiple selections
x = document.selection.GetTopPointX( eePosLogical, i ); // retrieve x of the left side of each selection
axT.push( x );
y = document.selection.GetTopPointY( eePosLogical, i ); // retrieve y of the left side of each selection
ayT.push( y );
x = document.selection.GetBottomPointX( eePosLogical, i ); // retrieve x of the right side of each selection
axB.push( x );
y = document.selection.GetBottomPointY( eePosLogical, i ); // retrieve y of the right side of each selection
ayB.push( y );
}
for( i = nCount - 1; i >= 0; --i ) {
document.selection.SetActivePoint( eePosLogical, axB[i], ayB[i] ); // set the cursor to the right side of each selection
document.selection.Text = sInsertAfter; // insert ']'
document.selection.SetActivePoint( eePosLogical, axT[i], ayT[i] ); // set the cursor to the left side of each selection
document.selection.Text = sInsertBefore; // insert '['
}