Yes, it is legal to index a symbol in an anonymous function. It is recommended, however, to initialize the symbol as a matrix.
e.g.,
A = sym('A',dim)
where
dim: Integer or vector of two integers specifying dimensions of A. For example, if dim is a vector [m n], then the syntax A = sym('A',[m n]) creates an m-by-n matrix of symbolic variables. If dim is an integer n, then the syntax A = sym('A',n) creates a square n-by-n matrix of symbolic variables.