If all the stems point outward, it's easy, as you've noticed. If the note with a different duration is in the middle of the chord, you can write the noteheads slightly out of alignment so they only touch the stem that applies to them.
For example, if you have, in the right hand of a piano score, a quarter note open fifth with a figure in sixteenth notes comprising pitches between the two quarter notes, you have four options.
If the quarter note stems point down and the sixteenth note stems point up, write the first sixteenth notehead slightly to the right, by perhaps half the width of a notehead.
If the quarter note stems point up and the sixteenth note stems point down, write the first sixteenth notehead slightly to the left instead.
If all the stems have to go in the same direction, give the noteheads a horizontal displacement of just a bit more than one notehead's width. This can be tricky. You will need to have the sixteenth notes spaced rather farther from each other than the horizontal distance between the quarter noteheads and the first sixteenth. I think it would be easier to read if the quarters were to the right of the first sixteenth, but I'm not certain of it.
Bach's solo violin and keyboard works frequently use a notation style in which simultaneously sounded notes do not share their stems. It might be interesting to look through these for some inspiration.
Lilypond does this automatically to some extent and provides a way of overriding the automatic layout. MuseScore does it as well.
This can be achieved in ABCjs with y:
X: 1
K: c
L:1/2
%%score (T1 T2)
V:T1 clef=bass stem=up
V:T2 clef=bass stem=up
[V:T1] [A,,/2E,G,]
[V:T2] y/32C,/16
Or
X: 1
K: c
L:1/2
%%score (T1 T2)
V:T1 clef=bass stem=up
V:T2 clef=bass stem=up
[V:T1] [A,,/2E,G,] [A,,/2E,G,] | [F,/2A,/2]
[V:T2] y/32D,/4C,/4 B,,/4^C,/4 D,/2
Clearer:
X: 1
K: c
L:1/2
%%score (T1 T2)
V:T1 clef=bass stem=up
V:T2 clef=bass stem=down
[V:T1] y/32[A,,/2E,G,] [A,,/2E,G,] | [F,/2A,/2]
[V:T2] D,/4C,/4 B,,/4^C,/4 y/32 D,/2