Back in 2006 Nick Cox provided an ado file to rename individual columns/rows of a matrix in this archived Stata blog:
Code:
// NJC 1.0.0 17 November 2006
// matrix row_or_column rename
program matrcrename
        version 8
        // syntax matrixname row_or_col which_row_or_col new_name

        // matrix name
        gettoken matrix 0 : 0
        confirm matrix `matrix'

        // row or column
        gettoken which 0 : 0
        local length = length("`which'")
        if lower("`which'") == substr("row",1,`length') {
                local which row
        }
        else if lower("`which'") == substr("column",1,`length') {
                local which col
        }
        else {
                di as err "second argument should specify row or column"
                exit 198
        }

        // which row or column
        gettoken where newname : 0
        if "`which'" == "row" {
                capture local found = inrange(`where', 1, rowsof(`matrix'))
                if _rc {
                        di as err "inappropriate row number?"
                        exit 498
                }
                if !`found' {
                        di as err "row out of range"
                        exit 498
                }
        }
        else {
                capture local found = inrange(`where', 1, colsof(`matrix'))
                if _rc {
                        di as err "inappropriate column number?"
                        exit 498
                }
                if !`found' {
                        di as err "column out of range"
                        exit 498
                }
        }

        // test newname
        tempname moo
        matrix `moo' = J(1,1,1)
        capture matrix rownames `moo' = `newname'
        if _rc {
                local what = cond("`which'" == "col", "column", "row")
                di as err "inappropriate `what' name?"
                exit 498
        }

        // in business!
        local names : `which'names `matrix'
        tokenize `names'
        local `where' `newname'
        local newnames "`*'"
        matrix `which'names `matrix' = `newnames'
end
My question (for Nick) is if this useful piece of code was integrated in some other (published) ado file; as matrcrename is not available on the ssc server.

If not, my suggestion (to Nick) is to make matrcrename available to the Stata user community by publishing it on the ssc server.
Although I have not tested it 'deep', it actually works as it should (I am using Stata 16.1, Rev. 20200331).

Many thanks in advance.