You need to extract the pitches and format them like this
myFunction =
#(define-music-function (myChord) (ly:music?)
(let* ((elts (ly:music-property myChord 'elements))
(pitches (map (lambda (x) (ly:music-property x 'pitch)) elts))
(pitches (filter (lambda (x) (not (null? x))) pitches))
(pitch-strings (map (lambda (x) (note-name->markup x #t)) pitches)))
#{
$myChord ^\markup $pitch-strings
#}))
or maybe like this
#(define (format-pc pitch)
(define (impl pitches)
(if (null? pitches)
(ly:error "Pitch name does not exist!")
(let ((p (cdar pitches)))
(if (and (= (ly:pitch-notename pitch) (ly:pitch-notename p))
(= (ly:pitch-alteration pitch) (ly:pitch-alteration p)))
(caar pitches)
(impl (cdr pitches))))))
(symbol->string (impl pitchnames)))
myFunctionII =
#(define-music-function (myChord) (ly:music?)
(let* ((elts (ly:music-property myChord 'elements))
(pitches (map (lambda (x) (ly:music-property x 'pitch)) elts))
(pitches (filter (lambda (x) (not (null? x))) pitches))
(pitch-strings (map format-pc pitches)))
#{
$myChord ^\markup $pitch-strings
#}))
Or maybe something like this if you want Lilypond code output
myFunctionIII =
#(define-music-function (myChord) (ly:music?)
#{
$myChord ^\markup #((@ (lily display-lily) music->lily-string) myChord)
#})