I made some changes to the code to get the coordinates in DMS, if necessary.
Only adjustments to the EPSG information are needed.
Latitude
(CASE WHEN $y < 0 THEN '-' ELSE '' END) || floor (abs(Y( transform( $geometry, 'EPSG:31983', 'EPSG:4326'))
)) || '°' || floor(((abs(Y( transform( $geometry, 'EPSG:31983', 'EPSG:4326'))
)) - floor (abs(Y( transform( $geometry, 'EPSG:31983', 'EPSG:4326'))
))) * 60) ||'\'' || substr( (tostring((((abs(Y( transform( $geometry, 'EPSG:31983', 'EPSG:4326'))
)) - floor (abs(Y( transform( $geometry, 'EPSG:31983', 'EPSG:4326'))
))) * 60) - floor(((abs(Y( transform( $geometry, 'EPSG:31983', 'EPSG:4326'))
)) - floor (abs(Y( transform( $geometry, 'EPSG:31983', 'EPSG:4326'))
))) * 60)) * 60),1,5) || '"'
Longitude
(CASE WHEN $x < 0 THEN '-' ELSE '' END) || floor (abs(X( transform( $geometry, 'EPSG:31983', 'EPSG:4326'))
)) || '°' || floor(((abs(X( transform( $geometry, 'EPSG:31983', 'EPSG:4326'))
)) - floor (abs(X( transform( $geometry, 'EPSG:31983', 'EPSG:4326'))
))) * 60) ||'\'' || substr( (tostring((((abs(X( transform( $geometry, 'EPSG:31983', 'EPSG:4326'))
)) - floor (abs(X( transform( $geometry, 'EPSG:31983', 'EPSG:4326'))
))) * 60) - floor(((abs(X( transform( $geometry, 'EPSG:31983', 'EPSG:4326'))
)) - floor (abs(X( transform( $geometry, 'EPSG:31983', 'EPSG:4326'))
))) * 60)) * 60),1,5) || '"'