The Supreme Court appeared closely divided on whether states and localities can ban AR-15s and similar semiautomatic rifles.